Hi everyone,
I want to make a flashlight tool, but unfortunately the light only shows up on the client’s side.
Here’s a LocalScript inside the tool (it works fine)
local cam = workspace.CurrentCamera
local RS = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Clone = RS:WaitForChild("LightPart"):Clone()
Clone.Parent = script.Parent
local Brightness = 10
local Keybind = Enum.KeyCode.F
local UIS = game:GetService("UserInputService")
local Toggle = false
local Mouse = game.Players.LocalPlayer:GetMouse()
local TS = game:GetService("TweenService")
local TI = TweenInfo.new(.1, Enum.EasingStyle.Sine)
UIS.InputBegan:Connect(function(Input, p)
if script.Parent.Equipped then
if p then return end
if Input.KeyCode == Keybind then
Toggle = not Toggle
end
else
return
end
end)
script.Parent.Unequipped:Connect(function()
Toggle = false
end)
RunService.RenderStepped:Connect(function()
if Clone then
Clone.Position = cam.CFrame.Position
TS:Create(Clone, TI, {CFrame = CFrame.lookAt(Clone.Position, Mouse.Hit.Position)}):Play()
if Toggle then
TS:Create(Clone.SpotLight, TI, {Brightness = Brightness}):Play()
else
TS:Create(Clone.SpotLight, TI, {Brightness = 0}):Play()
end
end
end)
The LocalScript works well on the client’s side, but I want all the players to see the light move. Is there any way to “convert” this script to server-side so it shows up for all players?
Thanks for any help!