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

How to turn my local script into a server script?

So, i have this script that toggles a trail in my game. There's a version of the script for two different trails, and a toggle all, in case that changes anything. I want to make it a server script, so everyone can see when someone toggles their trail.

local gui = script.Parent
local button = gui.ImageButton
local frame = gui.Frame

local function onClick() -- Create the function
	if frame.Visible == true then -- If the frame is seen, disable the visibility, otherwise enable it.
		frame.Visible = false
	else
		frame.Visible = true
	end
end

button.MouseButton1Click:connect(onClick) -- onClick is the function name. MouseButton1Click is the event.

1 answer

It should be fine to change it to a server script also you can change the onClick Function to this

local function onClick() -- Create the function
	frame.Visible = not frame.Visible
end

2 comments

0

I have changed it to a character script, but a get a nil error with 'Character.'

0

is it attempt to index nil with Character if yes then check if game.players.localplayer is there if its a localscript

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