Hi, i have problem with remote events. i write ReplicatedStorage.SpawnZombie:FireAllClients(). But in local script it gets wierd… sometimes event is not getting activated in local script. gets activated more times than it was fired on server…
Please show us your script, so we can see it.
3 Likes
function Zombie.Spawn(Zombie,path, startingpoint)
local ZombieInfo = ZombieInfoModule[Zombie]
local zInfo = {
["Name"] = ZombieInfo.Name;
["HP"] = ZombieInfo;
["Path"] = path;
["Position"] = startingpoint.CFrame;
["Speed"] = ZombieInfo.Speed;
["Node"] = 1;
}
local clientInfo = {
["Name"] = ZombieInfo.Name;
["Position"] = startingpoint.CFrame;
["Speed"] = ZombieInfo.Speed;
["ID"] = id
}
local zombiemodel = Instance.new("Model")
zombiemodel.Parent = game.Workspace.TempZombies
zombiemodel.Name = tostring(id)
ReplicatedStorage.SpawnZombie:FireAllClients(clientInfo,id)
id += 1
zombiemodel:SetAttribute("Name",zInfo.Name)
--zInfo.Position = zInfo.Position + Vector3.new(0,((1.043+ ReplicatedStorage.Zombies[zInfo.Name].PrimaryPart.Size.Y / 2) - (game.Workspace.Mapa["Ważne"].ZombieRespawn.Position.Y/2)),0)
local num = 0
RunService.Heartbeat:Connect(function()
zInfo.Position = zInfo.Position:ToWorldSpace(CFrame.new(Vector3.new(0,0,ZombieInfo.Speed)))
if (workspace.WalkPoints[zInfo.Node].Position - zInfo.Position.Position).Magnitude <= 0.5 then
zInfo.Node += 1
zInfo.Position = CFrame.lookAt(zInfo.Position.Position, workspace.WalkPoints[zInfo.Node].Position)
end
if num < 10 then
clientInfo.Position = zInfo.Position
ReplicatedStorage.ZombieClient:FireAllClients(clientInfo)
end
end)
end
and local script
Replicatedstorage.SpawnZombie.OnClientEvent:Connect(function(ZombieInfo,modelName)
print("Spawn")
local clientmodel = Replicatedstorage.Zombies:FindFirstChild(ZombieInfo.Name)
local x = clientmodel:Clone()
x.Parent = workspace.TempZombies:FindFirstChild(tostring(modelName))
x.PrimaryPart.CFrame = ZombieInfo.Position
local anim = x.AnimationController:LoadAnimation(x.Animations.Walk)
anim:Play()
end)
the event i was talking about is SpawnZombie
I think firing a remote event multiple times per frame is not allowed i.e.
for i = 1, 100 do
remote:FireAllClients(i)
end
clients would only receive 100
. I cannot find anything about this online though, just what i’ve noticed.