When you reach a certain amount of Coins, A GUI changes


I am making a quest system. I’ve made a point system and named it Coins. player.leaderstats.Coins.Value = 125
Then,
script.Parent.Parent.Point1.Visible = false
script.Parent.Visible = true

Do I make it a Local Script? I’m very confused about what to do. I have searched around the DevForum and I couldn’t find a similar topic?

Any sort of help is appreciated.


4 Likes

Yes, make it a local script. Because this only works in a client unless you use game.Players.PlayerAdded

1 Like

I don’t fully understand. You are trying to make a money gui that will show your money ?

1 Like

Do this is in a local script. Exploiters viewing GUIs they’re not supposed to won’t actually break your game.

Firstly, make a function that checks the coins value before updating the GUIs. If it’s just to show how many coins, set the Text property to the same as the coins Value property. I’m guessing your scenario is more sophisticated, so you may need to run a couple if statements to verify which GUIs should be open based off the coins.Value. Use inequality signs < and > to help you.

At the end of the script, simply bind this function to this event:

player.Leaderstats.Coins.Value.Changed:Connect(myFunc)

Hope it works!

1 Like

For anyone who doesn’t know my situation. As I said, I’m making a Quest system.
I want to make a script that when you reach 125 Coins it will activate a ProximityPrompt and the GUI changes.

player.leaderstats.Coins.Value = 0
1

player.leaderstats.Coins.Value = 125
2

This is my script:

if player.leaderstats.Coins.Value >= 125 then
	game.Workspace.Part.ProximityPrompt.Enabled = true
	script.Parent.Parent.Point1.Visible = false
	script.Parent.Visible = true
end 

My script doesn’t work, Mind helping me out? Any sort of help and support is wanted and is appreciated by anyone here!

Your script should work perfectly. The only thing you haven’t done correctly is connect it to a Changed event:

function verifyCoins(player)
    if player.leaderstats.Coins.Value >= 125 then
    	game.Workspace.Part.ProximityPrompt.Enabled = true
    	script.Parent.Parent.Point1.Visible = false
    	script.Parent.Visible = true
    else return "NAN" end
end

game.Players.PlayerAdded:Connect(function(plr)
    -- Data store code and value instancing goes here
    if verifyCoins(plr) == "NAN" then 
        plr.leaderstats.Coins.Changed:Connect(function()
            verifyCoins(plr)
        end)
    end
end)
1 Like

yes this script can work. (if that’s what she wants) :smiley:

1 Like

I’m not sure why it didn’t work since it is fine and there was no error in the Output. Where do I place my script? But for now, I’ll mark you as a Solution Post since I find that there is no error in the Script. But it somehow doesn’t work.

you have no errors, but you typed the script incompletely.

1 Like

The script should be placed in ServerScriptService.

Also, if it still doesn’t work, rewrite the code within the if statement of the “verifyCoins” functions. It’s probably to do with these instances; I had no further insight into them.

1 Like

It worked, Thank you for your support. I’m sorry for wasting your time! Thank you truly!

I am glad i can help you :slightly_smiling_face:

1 Like