I am trying to make client sided movement for a tower defense game I’m working on.
I use a server side script for the absolute position and a local script for the visual representation of the enemy (to avoid replication stutter).
Now my issue is that while the attachments do get set:
It doesn’t move the enemies on the client, they aren’t anchored and the force and velocity are the same as the ones on the server so that shouldn’t be an issue.
As you see the ducks (enemies) aren’t moving but the parts are (the parts are spawned on the server and parented to a folder in workspace)
The way I try to move the enemies on the client is by setting Attachment1 to the server enemies attachment. I am passing the correct parameters and they do work and don’t print nil, it’s just that it’s not moving the client enemy.
I am not sure of the issue and this should work but it just doesn’t.
Here is the local script I use to spawn it on the client and make it work (StarterPlayerScripts)
– << Services >> –
local RS = game:GetService(“ReplicatedStorage”)– << Variables >> –
local events = RS:WaitForChild(“Events”)
local clientEnemy = events:WaitForChild(“ClientEnemy”)local enemiesFolder = RS:WaitForChild(“EnemiesClient”)
local enemiesF = workspace.Enemies
– << Functions >> –
clientEnemy.OnClientEvent:Connect(function(enemy, serverEnemy)
local enemyName = enemy.Namelocal newEnemy = enemiesFolder:FindFirstChild(enemyName … “Client”):Clone()
if newEnemy then
local root = newEnemy:FindFirstChild(“HumanoidRootPart”)local alignPos = root:FindFirstChildOfClass("AlignPosition") local rotPos = root:FindFirstChildOfClass("AlignOrientation") newEnemy.HumanoidRootPart.Position = workspace.Map.Waypoints.waypoints1.EnemySpawn.Position newEnemy.Parent = workspace.ClientEnemy alignPos.Attachment1 = serverEnemy.HumanoidRootPart.Node rotPos.Attachment1 = serverEnemy.HumanoidRootPart.Node print(alignPos.Attachment0) print(alignPos.Attachment1)
else
warn(“No enemy found”)
end
end)