Alright, so, I’m making a TDS game.
However, I wanted to handle spawning on the client to prevent server lag (event is fired on all clients);
function spawn_enemy(data)
--
local model = data.model:Clone()
local humanoid = model.Humanoid
local animator = humanoid.Animator
--
local attributes = model.attributes
local health_data = model.health_data
local resistances = model.resistances
local stats = model.stats
--
local map = _G.map
model.Parent = map
--
local thread
local walk_anim = animator:LoadAnimation(model.walk)
walk_anim:Play()
--
model.Parent = _G.map.enemies
_G.follow_path({
["model"] = model;
["nodes_folder"] = _G.map.nodes_folder
}) -- they follow the nodes
--
end
spawn_enemy_event.OnClientEvent:Connect(spawn_enemy)
An issue is latency.
For some clients, the enemy will spawn later/earlier than other clients, making it inconsistent.
And if someone is really laggy, an enemy might make it to their base before they even realize that it’s spawned yet.
How would I achieve this? How would I sync the enemy position with all clients?