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

How to turn my local script into a server script?

Asked by 2 years ago

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

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
2 years ago

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
0
I have changed it to a character script, but a get a nil error with 'Character.' NightminerYT 2 — 2y
0
is it attempt to index nil with Character if yes then check if game.players.localplayer is there if its a localscript Puppynniko 1059 — 2y
Ad

Answer this question