Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 6 years ago

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

Log in to vote
0
Answered by 6 years ago

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.

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! Doglover9190 4 — 6y
0
And also I thought I had filtering enabled off, but put streaming enabled off. :P Doglover9190 4 — 6y
0
I'll approve if you don't have the script for that. Doglover9190 4 — 6y
Ad

Answer this question