Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My gui 'locked' script only works partly?

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

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.

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.