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

This OnClicked event only works in studio? (In a brick with a click detector)

So I'm making a clicking thing, and every time you click a brick the brick changes color, changes your click value in Workspace, and updates the GUI that says how many clicks you have. It works perfectly fine in studio, but in the real thing, it doesn't work. Help? Here is the code.

function onClicked(playerWhoClicked)
	game.Workspace.Clicks.Value = game.Workspace.Clicks.Value + 1
	game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.TextLabel.Text = ("Clicks : ".. game.Workspace.Clicks.Value)
	script.Parent.BrickColor = BrickColor.random()
end
script.Parent.ClickDetector.MouseClick:connect(onClicked)

If you could help it would be greatly appreciated. Thanks!

1 answer

✓ Accepted answer

FilteringEnabled is turned on. Keep it on, just update your scripts.

You shouldn't really need a RemoteEvent in this case so;

In a ServerScript, put;

function onClicked(playerWhoClicked)
    game.Workspace.Clicks.Value = game.Workspace.Clicks.Value + 1
    script.Parent.BrickColor = BrickColor.random()
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)

Then make a LocalScript, in the TextLabel, and in it put;

game.Workspace.Clicks.Changed:Connect(function()
    script.Parent.Text = ("Clicks : " .. game.Workspace.Clicks.Value)
end)

If you want it to record only how many times one person has clicked the button, that's a whole different story. Reply to this if that's what you need.

3 comments

0

Well actualy, that would be nice.. because I only know how to do it for one player. If you could do it, thanks! If you can't thanks anyway!

0

And also I thought I had filtering enabled off, but put streaming enabled off. :P

0

I'll approve if you don't have the script for that.

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