Hello,
I am trying to make the text on a TextButton change depending on the time someone has spent in the game. The time spent in the game is saved as a leaderstat. However, the script I have used is not working and I have no clue why. Could someone help me?
local players = game:GetService("Players")
local player = players.LocalPlayer
local Time = player:WaitForChild("leaderstats").Time.Value
local Redeem = script.Parent.UGCFrame.Redeem
if Time >= 17 then
Redeem.Text = "REDEEM"
Redeem.LocalScript.Enabled = true
else
Redeem.Text = "LOCKED"
end
this is probably the most efficient method, it will only read value changes
local players = game:GetService("Players")
local player = players.LocalPlayer
local Time = player:WaitForChild("leaderstats").Time
local Redeem = script.Parent.UGCFrame.Redeem
function Update()
if Time.Value >= 17 then
Redeem.Text = "REDEEM"
Redeem.LocalScript.Enabled = true
else
Redeem.Text = "LOCKED"
end
end
Update()
Time:GetPropertyChangedSignal("Value"):Connect(Update)
local players = game:GetService("Players")
local player = players.LocalPlayer
local Time = player:WaitForChild("leaderstats").Time
local Redeem = script.Parent.UGCFrame.Redeem
Time:GetPropertyChangedSignal("Value"):Connect(Function()
if Time.Value >= 17 then
Redeem.Text = "REDEEM"
Redeem.LocalScript.Enabled = true
else
Redeem.Text = "LOCKED"
end
end)
I never understood why people do the way you did it