Попытка проиндексировать номер с помощью «Текст», как исправить?
Я пытаюсь создать набор меток, которые обновляются каждые 2,5 секунды до значений атрибутов игрока, однако моя попытка не работает, как я могу это исправить?
local StrenghtButton = script.Parent.Frame.Strenght
local DFButton = script.Parent.Frame.DevilFruit
local SwordButton = script.Parent.Frame.Sword
local StrenghtLabel = script.Parent.Frame.StrenghtLabel
local DFLabel = script.Parent.Frame.DFLabel
local SwordLabel = script.Parent.Frame.SwordLabel
local AvaiblePoints = script.Parent.Frame.AttributePointsIndicator
local Frame = script.Parent.Frame
local StatsMenu = script.Parent.StatsMenu
local Player = game.Players.LocalPlayer
local AvaiblePoints = Player:GetAttribute("AvaiblePoints")
local StrenghtValue = Player:GetAttribute("Strenght")
local DFValue = Player:GetAttribute("DevilFruit")
local SwordValue = Player:GetAttribute("Sword")
while true do
task.wait(2.5)
AvaiblePoints.Text = "Avaible Points - " .. AvaiblePoints
StrenghtLabel.Text = "Strenght - " .. StrenghtValue
DFLabel.Text = "Devil Fruit - " .. DFValue
SwordLabel.Text = "Sword - " .. SwordValue
end
StrenghtButton.MouseButton1Click:Connect(function()
if AvaiblePoints >= 1 then
Player:SetAttribute("Strenght", StrenghtValue+1)
end
end)
DFButton.MouseButton1Click:Connect(function()
if AvaiblePoints >= 1 then
Player:SetAttribute("DevilFruit", DFValue+1)
end
end)
SwordButton.MouseButton1Click:Connect(function()
if AvaiblePoints >= 1 then
Player:SetAttribute("Sword", SwordValue+1)
end
end)
1 ответ
Вы отображаете те же значения для ваших меток вwhile
цикл, значения, которые вы изначально извлекли для каждого атрибута, сохраняются в той же переменной, которая затем отображается.
Вместо повторного использования одной и той же переменной вам нужноGetAttribute()
каждый раз, когда вы визуализируете свою метку, чтобы получить текущее значение.
while true do
task.wait(2.5)
AvaiblePoints.Text = "Avaible Points - " .. Player:GetAttribute("AvaiblePoints")
StrenghtLabel.Text = "Strenght - " .. Player:GetAttribute("Strenght")
DFLabel.Text = "Devil Fruit - " .. Player:GetAttribute("DevilFruit")
SwordLabel.Text = "Sword - " .. Player:GetAttribute("Sword")
end