Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My gui 'locked' script only works partly?

Asked by
Omzure 94
5 years ago

I'm making a gui lock script where if you have under a certain amount of cash, an upgrade button would say 'LOCKED' and if it went over, it would say what the upgrade is and stuff..

Part of the script works... only the first part where it says that the upgrade is locked, but the other half won't work and there is NO errors in the output...

anyways, here's the lock script (local script inside screen gui)


local upg5T = script.Parent.upg5 local plr = game.Players.LocalPlayer if plr.leaderstats.Cash.Value < 150000 then upg5T.Text = "LOCKED" elseif plr.leaderstats.Cash.Value > 150000 then upg5T.Text = "UNLOCKED" wait(2) upg5T.Text = "blabla" if plr.leaderstats.Cash.Value < 150000 then upg5T.Text = "blabla" end end

1 answer

Log in to vote
2
Answered by 5 years ago

You're just checking the value once the script runs, that is why it is not working, What you have to do is the event called ".Changed" That runs everytime the value changed, so it would be:

local upg5T = script.Parent.upg5
local plr = game.Players.LocalPlayer
plr.leaderstats.Cash.Changed:Connect(function()  
    if plr.leaderstats.Cash.Value < 150000 then
        upg5T.Text = "LOCKED"
    elseif plr.leaderstats.Cash.Value >= 150000 then
        upg5T.Text = "UNLOCKED"
        wait(2)
        upg5T.Text = "blabla"   
    end
end)

This will check everytime that value changed, I hope I helped. If you got any question, Reply me.

0
sorry for the late post, but i was actually heading for when you unlock it it cannot be locked again once it goes under the unlock value. Omzure 94 — 5y
Ad

Answer this question