heres basically the problem now
Im pretty sure this script should work
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
local waypoints = game.Workspace.EntityPoints:GetChildren()
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
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)
ok Ill just try to raise up the cframe by 5
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
local waypoints = game.Workspace.EntityPoints:GetChildren()
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
local currentWaypoint = 1
part.CFrame = startCFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame
startCFrame = part.CFrame * CFrame.new(0,5,0)
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
end
end)
afraid tosay same problem idk why this is so difficult
I made a mistake, try this
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
local waypoints = game.Workspace.EntityPoints:GetChildren()
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
local currentWaypoint = 1
part.CFrame = startCFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame * CFrame.new(0,5,0)
startCFrame = part.CFrame
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
end
end)
again the same problem nothing changed
wait I just realized currentwaypoint is getting resett everytime meaning it will pretty much never change the poistion. use this script I think it should fix it, if it doesnt then I really dont know what is going wrong
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
local waypoints = game.Workspace.EntityPoints:GetChildren()
local currentWaypoint = 1
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = runningTime / lerpTime
part.CFrame = startCFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame * CFrame.new(0,5,0)
startCFrame = part.CFrame
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
end
end)
works! jjust a bit fast LOL he’s zipping around crazy fast
is there a way i can make him move smoothly and not “get to the next waypoint in specific time”
I think this is how you can change the speed instead of time. just change the speed variable the more it is the faster
local RunService = game:GetService(“RunService”)
local part = script.Parent
local startCFrame = part.CFrame
local runningTime = 0
local lerp
local waypoints = game.Workspace.EntityPoints:GetChildren()
local currentWaypoint = 1
local distance = (startCFrame.Position-waypoints[1].CFrame.Position).Magnitude
local speed = 1
lerp = RunService.Heartbeat:Connect(function(deltaTime)
runningTime += deltaTime
alpha = (runningTime * speed) / distance
part.CFrame = startCFrame:Lerp(waypoints[currentWaypoint].CFrame*CFrame.new(0,5,0), alpha)
if alpha >= 1 then
part.CFrame = waypoints[currentWaypoint].CFrame * CFrame.new(0,5,0)
startCFrame = part.CFrame
currentWaypoint += 1
runningTime = 0
if currentWaypoint > #waypoints then
currentWaypoint = 1
end
distance = (startCFrame.Position-waypoints[currentWaypoint].CFrame.Position).Magnitude
end
end)
thank you my friend for all the help
here game
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.