[Edited with my code]
Hello,
I want to make a button that will disable/enable a trail in the workspace through StarterGUI.
I have the button already made, and here is the code I have:
local trail = workspace.RainbowTrail.Trail function OnButtonClick() if trail.Enabled == false then trail.Enabled = true end if trail.Enabled == true then trail.Enabled = false end end
The trail is a child of a script (I got the trail from the toolbox), and is in the workspace.
Any help is welcome!
Thanks in advance, MexheCo
LocalScript
and under your button.-- LocalScript, under your button local trail = game.Workspace.RainbowTrail.Trail function OnButtonClick() trail.Enabled = not trail.Enabled -- Save some lines of code! Simple way to toggle a boolean. end script.Parent.MouseButton1Click:Connect(OnButtonClick) -- event listens for the gui being clicked
Thanks for the help. It's still not working though, probably user error on my part :P
I changed my "Script" to "LocalScript" and pasted your code in.
I also changed the location of the "RainbowTrail" script (which was in Workspace) into ServerScriptService.
Now I have this:
local trail = game.ServerScriptService.RainbowTrail.Trail function OnButtonClick() trail.Enabled = not trail.Enabled end script.Parent.MouseButton1Click:Connect(OnButtonClick)
Any reason why this wouldn't be working?
Thanks again, MexheCo