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

What is wrong with this TextButton clicked script?

So basically, when somebody clicks a textbutton, I want it to clone a dance floor from serverstorage and make a red-tinted screen. This should be on the server, I don't want it to be on one client. Here is the script I put below inside the textbutton (in a ServerScript)

function onClicked()
	game.ServerStorage.DanceFloor:clone().Parent = workspace
	local color = Instance.new('ColorCorrectionEffect', game.Lighting)
	color.TintColor = Color3.fromRGB(255, 172, 172)
end

script.Parent.MouseButton1Down:connect(onClicked)

In studio, it works. But in the game, it doesn't. I know most guis are powered from LocalScripts, but this is supposed to affect everyone so I tried a regular Script. What did I do wrong? How can I fix this?

1 answer

✓ Accepted answer

The type of script does not relate to who the script effects. In order for the MouseButton1Down event to work, I believe you will need to be using a LocalScript. The rest of the code should work fine if filteringenabled is OFF, although if it's on then this will only affect the local player.

You can bypass this by using remoteevents, although that's a whole new question entirely.

3 comments

0

If it's local it won't be able to access ServerStorage

0

I know, I moved it to ReplicatedStorage

0

That too, lol, can't believe I didn't notice that. Thanks

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