function enemy.WalkToWayPoint(thing, timeEachCooldown, position)
if thing.State == "Dead" then return end
if thing.CurrentWaypoint + 1 > #map.Waypoints:GetChildren() then return end
local nextWaypoint = map.Waypoints[thing.CurrentWaypoint + 1]
thing.CFrame *= CFrame.new(0, 0, -(thing.Speed / timeEachCooldown)
if (thing.CFrame.Position - nextWaypoint.Position).Magnitude < 1 then
thing.CurrentWaypoint += 1
end
end
Also consider removing entities from mobss that are dead/reached end to save resources
local ts = game:GetService("TweenService")
local EntityMap = {}
game.ReplicatedStorage.Events.Render.OnClientEvent:Connect(function(enemy)
if enemy and not EntityMap[enemy.ID] then
EntityMap[enemy.ID] = enemy
local enemyInstance = enemy.Instance
enemyInstance = enemyInstance:Clone()
enemyInstance.Parent = workspace.Enemies
enemyInstance.HumanoidRootPart.CFrame = workspace["Crash Test Zone"].Waypoints[1].CFrame
for i,v in pairs(enemyInstance:GetChildren())do
if v:IsA("BasePart") or v:IsA("MeshPart") then
v.CollisionGroup = "Enemy"
end
end
enemy.Instance = enemyInstance
end
end)
game.ReplicatedStorage.Events.Render.OnClientEvent:Connect(function(enemy, TimeToReach)
if EntityMap[enemy.ID] then
print("yes")
local enemyInstance = EntityMap[enemy.ID].Instance
local waypoint = EntityMap[enemy.ID].CurrentWaypoint
waypoint += 1
local goal = {}
goal.Position = Vector3.new(workspace["Crash Test Zone"].Waypoints[waypoint].Position.X,enemyInstance.HumanoidRootPart.Position.Y, workspace["Crash Test Zone"].Waypoints[waypoint].Position.Z)
local moving = ts:Create(enemyInstance.HumanoidRootPart, TweenInfo.new(TimeToReach/10), goal)
moving:Play()
end
end)
In this video the guy is sliding like that, any fix? nvm i cant upload it for some reason but he keeps sliding on until the end of the map also his speed is fast when his walkspeed is 4
Also after the first tween he doesnât seem to move at all
Server side is looping through the table of info and sending an event to all the elements
It seems you are extremely new to scripting and I urge you to watch tutorials. I understand they may be hard for people like you to comprehend but at least attempt understanding how concepts like print() work.How To Script On Roblox - Episode 1 (Properties) - YouTube