i’d much rather it run on client
but i changed it to heartbeat and…
what happened I cant tell much from the picture
well ill show you what i had before hold up
heres what it was
basically ambush was a humanoid and just used moveto
robloxapp-20240416-1745072.wmv (5.3 MB)
heres it now
(i put ambush in the workspace to make it a bit faster but you would spawn him in)
robloxapp-20240416-1747069.wmv (1.6 MB)
sorry about it being downloadable files
change the runservice loop to this and I think at least his head would be out of the ground
lerp = RunService.RenderStepped:Connect(function(deltaTime)
runningTime += deltaTime
alpha = deltaTime / lerpTime
part.CFrame = part.CFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(5), alpha)
if (part.CFrame.Position-waypoints[currentWaypoint].CFrame.Position) <= 0.5 then
part.CFrame = waypoints[currentWaypoint].CFrame*CFrame.new(5)
currentWaypoint += 1
end
end)
it doesnt work with renderstepped but i changed it to heartbeat and i got loads of errors attempt to index with nil because i removed some variables by accident so i put them back and i get
17:56:35.009 Workspace.Ambush.HumanoidRootPart.Script:17: invalid argument #1 to ‘new’ (Vector3 expected, got number) - Server - Script:17
also just realised i left targetcframe in thats from when i was doing the tutorial so thats not related
the script I gave you has a mistake replace it with this
lerp = RunService.RenderStepped:Connect(function(deltaTime)
runningTime += deltaTime
alpha = deltaTime / lerpTime
part.CFrame = part.CFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if (part.CFrame.Position-waypoints[currentWaypoint].CFrame.Position) <= 0.5 then
part.CFrame = waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0)
currentWaypoint += 1
end
end)
18:02:19.211 Workspace.Ambush.HumanoidRootPart.Script:18: attempt to compare Vector3 <= number - Server - Script:18
I forgot to fix the earlier bug, also fixed another bug in this
lerp = RunService.RenderStepped:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
part.CFrame = part.CFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if (part.CFrame.Position-waypoints[currentWaypoint].CFrame.Position).Magnitude <= 0.5 then
part.CFrame = waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0)
currentWaypoint += 1
runningTime = 0
end
end)
well your not wrong his head is above the ground buttt he just slides to a waypoint and stops
ok try changing lerptime to 0.1 and see if it moves
also replace this part
if (part.CFrame.Position-waypoints[currentWaypoint].CFrame.Position).Magnitude <= 0.5 then
part.CFrame = waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0)
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #watypoints then
currentWaypoint = 1
end
end
you spelt waypoints wrong btw
he goes to a waypoint but not all of them
if this one doesnt work then Idk how to solve it
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
part.CFrame = startcframe:Lerp(waypoints[currentWaypoint].CFrame, alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame
startcframe = part.CFrame
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
end
end)
you know he actually moves now just gets stuck
ambush does actually have a different collisiongroup so he shouldnt but he does anyways
ill try putting him on a flat surface
can you send the whole script again?
local RunService = game:GetService(“RunService”)
local part = script.Parent
local startCFrame = part.CFrame
local targetCFrame = part.CFrame * CFrame.new(0, 30, 0)
local lerpTime = 0.1
local startTime = tick()
local runningTime = 0
local lerp
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = deltaTime / lerpTime
local waypoints = game.Workspace.EntityPoints:GetChildren()
local currentWaypoint = 1
part.CFrame = startCFrame:Lerp(waypoints[currentWaypoint].CFrame, alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame
startcframe = part.CFrame
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
end
end)