Hi, I want to use the signal module script that everyone uses. It’s my first time using this script and it looked pretty easy to use.
All I did was create a signal and connect it as normal for my lantern to turn off and on for the server.
It works, but the problem is it only turns off and on for the client. How do I make it server?
local Lantern = {}
local Signal = require(game:GetService("ReplicatedStorage").Modules.Signal)
local On = true
local Debounce = true
local FX = Signal.new()
function Lantern.Function(actionName, inputState, _inputObjec)
if actionName ~= script.Name then
return
end
if inputState ~= Enum.UserInputState.Begin then
return
end
local Player = game.Players.LocalPlayer
if not Player.Character then
Player.CharacterAdded:Wait()
end
if Debounce == true then
Debounce = false
local Light = Player.Character:FindFirstChild("Lantern").LightPart
On = not On
FX:Connect(function()
if On then
Light.sfx:Play()
Light.PointLight.Enabled = true
Light.Color = Color3.fromRGB(218, 133, 65)
Light.Material = Enum.Material.Neon
else
Light.sfx:Play()
Light.PointLight.Enabled = false
Light.Color = Color3.fromRGB(0, 0, 0)
Light.Material = Enum.Material.Plastic
end
end)
if On then
FX:Fire()
else
FX:Fire()
end
wait(3)
Debounce = true
end
end
return Lantern
This Signal.new() basically creates a BindableEvent, which doesnt go across server/client boundary
If you want to send signals through the client/server boundary using connections, you have to use a RemoteFunction or RemoteEvent
Good to know. Although I saw a local script that used Signal.new() for making their sounds global. For example, If I wanted someone to hear my footstep sounds on the client, they would use Signal.new().
I am not sure how they got that to work.
So you’re saying there isn’t a way to do this with Signal?
If you want everything to replicate to the other clients, then yes.
For anything that you want the other clients to see, you will have to use RemoteEvents/RemoteFunctions.
I suggest reading up on them and watching tutorials on properly sanitising server code!