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

How would I make this appear server side?

Asked by 5 years ago

I'm making a simple flashlight right now and I was wondering how I could make it appear server-side instead of just client. The code is located in a Local Script in the StarterGui.

local mouse = game.Players.LocalPlayer:GetMouse()
function Toggle()
    local player = game.Players.LocalPlayer
    Local char = player.Character
    local active = char.Head:FindFirstChild("Light")
if active then
    active:Destroy()
script.Parent.Light.Frame.Icon.Image = "rbxassetid://"
else
    local light = Instance.new("PointLight",char:FindFirstChild("Head"))
    ---- blah light setting
    end
end
mouse.KeyDown:connect(function(key)
key = key:lower()
if key == "f" then
    Toggle()
end
end)

if there is any issues w/ this code then its probably because I typed it instead of copy and pasting it.

0
first erro i see is game.Players.LocalPlayer:GetMouse() replace that with game:GetService("Players").LocalPlayer:GetMouse() Gameplayer365247v2 1055 — 5y
0
second error i see is the key function, that function is patched so replace that with mouse.KeyDown:connect(function(key) if key == tostring("f") then Gameplayer365247v2 1055 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago

Remote events would be useful

https://developer.roblox.com/articles/Remote-Functions-and-Events

^^^ Thats how Remotes work

1
thanks! theGoodpancake 5 — 5y
Ad

Answer this question