I’m currently working on replicating a weapon’s effects, but it doesn’t seem to work, and it has something to do with the remote event I use to fire to all clients. (it is either not firing or the local script isn’t receiving anything) I checked all the variables, and none seem to have a typo. I’ve been looking around the DevForum, but I didn’t see any suitable answers. Any help would be appreciated!
Client code (When the weapon is activated) (parented to folder in tool)
zapperTool.Activated:Connect(function()
if not shot then
shot = true
tube.Material = Enum.Material.Neon
lens.Material = Enum.Material.Neon
zapperSound:Play()
fireZapperTrack:Play()
-- Creates beam effect
local beam = createBeam(lens.Position,mouse.Hit.Position,secondaryColor.Value.Color)
OnZap:FireServer(mouse.Hit.Position,zapperTool,secondaryColor.Value.Color)
tube.Material = Enum.Material.Glass
lens.Material = Enum.Material.Glass
wait(FIRE_RATE)
shot = false
end
end)
Server code (parented to folder in tool)
OnZap.OnServerEvent:Connect(function(player,position,zapper,beamColor)
for _,client in ipairs(Players:GetPlayers()) do -- Goes through every player, excpet the one who fired the weapon, and fires an event to replicated the effects)
if client == player then continue end
print("fired to " .. client.Name)
ReplicateZapperEffects:FireClient(client,zapper,position,beamColor)
end
print("determining raycast")
-- raycast code
end)
Client code (Replicating weapon effect) (parented to folder in tool)
ReplicateZapperEffects.OnClientEvent:Connect(function(zapper,position,beamColor)
print("recieved")
local lensP = zapper:WaitForChild("Lens")
local tubeP = zapper:WaitForChild("Tube")
local soundsP = lensP:WaitForChild("Sounds")
local zapperSoundP = sounds:WaitForChild("ZapperSound")
tubeP.Material = Enum.Material.Neon
lensP.Material = Enum.Material.Neon
zapperSoundP:Play()
local beamP = createBeam(lensP.Position,position,beamColor)
tubeP.Material = Enum.Material.Glass
lensP.Material = Enum.Material.Glass
end)
The problem is that I don’t know if the event, “ReplicatedWeaponEffects” is being fired or not because I don’t see the “received” message in the output of the client.