I'm trying to make a coin that gives you money when you click it but nothing happens. It's also meant to be for the player who clicks, and I don't know how to do that.
local click = script.Parent.ClickDetector click.MouseClick:connect(function() script.Parent.Sound:Play() intValue = workspace.Values.Riches.Value intValue.Value = intValue.Value + 1 game.StarterGui.Riches.TextLabel.Text = "" ..intValue.Value end)
I'm a bit of a noob, thanks if you can help!
See, the problem is that you're tryingto access the startergui, but the startergui is not where the textlabel is currently stored.
So, where is the textlabel stored? In the playergui, all contents of startergui get cloned to the playergui for every player when he joins
What would be a solution?
You can just make it Player.PlayerGui.Riches.TextLabel.Text
, however, I don't recommend that, it will get messy, use script.Parents instead.
Other problems 1) You didn't make it FE compatible (FE = filtering enabled), to prevent hackers from destroying your game, you should always enable that option, simply put your values inside the player and use some remotes.
2) Also a FE problem, you cannot access the contents of the playergui with a serverscript!
That's about all, if you need a quick script i recommend just changing game.StarterGui to player.PlayerGui (with player being the player that clicked the button)
But you should never forget FE.
If you have any more questions, just ask.
Edit, this script should work
local click = script.Parent.ClickDetector click.MouseClick:connect(function(plr) script.Parent.Sound:Play() intValue = workspace.Values.Riches.Value intValue.Value = intValue.Value + 1 plr:WaitForChild('PlayerGui'):WaitForChild('Riches'):WaitForChild('TextLabel').Text = tostring(intValue.Value) end)
Check this out, this question was asked not long before you: but it has Tweening ! Tweening is what you need for your job: https://scriptinghelpers.org/questions/60565/answered-why-wont-my-tweening-script-for-my-gui-work-in-the-player