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

How do I make text go up when a part is clicked?

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!

1 comment

0

Add a new script into the workspace. Type this: local stats = function(plr)

2 answers

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)

2 comments

0

I'm still kind of confused on what to do. I have Filtering Enabled and I changed it from StarterGUI to PlayerGUI, but it doesn't work.

0

I'll edit your script and put it on my answer

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