I’m Making A Game in that game you can buy things using the game currency but if The Player Does Not Have Enough Currency I want a gui to pop up, is there anyone who can give me instructions on how to do it
Make a GUI, Check if there currency isn’t enough on a server-sided script if its not enough make the GUI Visible.
if money >= 10 then
tool.Parent = plr
else
frame.Visible = true
end
--Make sure you define all this stuff or the script will not work.
Hope this helps.
where should this script be inserted
This could be put anywhere, either in your money system script or outside of it. You just have to define the variables:
- money
I suggest instead of using this to change it to money.Value if it’s a value object inside your game. - tool
- frame
i have this script…
script.Parent.ClickDect.MouseClick:Connect(function(player)
if player.leaderstats.Coins.Value <= 100 then
–what i want the script to do
end
script.Parent.ClickDect.MouseClick:Connect(function(player)
local errorGui = player.PlayerGui.ErrorGui
-- this is a screenGui, it's supposed to be disabbled at the start.
-- What you'd need in it is an X button to close the script.
if player.leaderstats.Coins.Value >= 100 then
-- give what they want
elseif player.leaderstats.Coins.Value < 100 then
-- not enough cash
errorGui.Enabled= true
end
end)
what you did wrong was when they had 100 or below you denied it, but as he got 100 bucks for example and he can’t buy it would be weird.
Note, instead of elseif ... then
you can just write else
instead as it should work as well.
if player.leaderstats.Coins.Value >= 100 then
– is that meant to check if a player has below 100?
end
Inside the if statement, you would make use of RemoteEvents
and fire a remote to that player and have a local script that waits for the remote to fire since GUI handling should always be done on the client locally.
No, that checks if the player has exactly 100 or more than 100 just look at the sign like this:
It’s just a mnemonic, and the variable/number on the side which is bigger is then supposed to be bigger than the other part.