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

Need help with if you dont have enough cash you can not click the gui button can someone help?

Asked by 1 year ago
Edited by ScriptGuider 1 year ago

so what im trying to do is, is that i need to make it so if you dont have enough cash the button is not active. I tried this but it did not work

local currencyNeeded = 10           
local plr = game.Players:GetPlayerFromCharacter()


if plr.leaderstats.Cash.Value >= currencyNeeded then 
    game.StarterGui.PlacementGui.Frame.Ranged.Active = true
else
    game.StarterGui.PlacementGui.Frame.Ranged.Active = false
end
0
What type of script are you using to do this? local or normal? Codyslx 0 — 1y

1 answer

Log in to vote
0
Answered by 1 year ago
Edited 1 year ago

You are editing the active value in startergui instead of the player's gui. Instead, use plr.PlayerGui, like this.

local currencyNeeded = 10           
local plr = game.Players:GetPlayerFromCharacter()


if plr.leaderstats.Cash.Value >= currencyNeeded then 
    plr.PlayerGui.PlacementGui.Frame.Ranged.Active = true
else
    plr.PlayerGui.PlacementGui.Frame.Ranged.Active = false
end

Let me know if this helps.

Ad

Answer this question