Well i am trying to make back in time ability sort of,
So some Times When i use the ability it gone give me error " Unable to assign property CFrame. CoordinateFrame expected, got nil "
The script
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local HumanoidRootPart = Character:FindFirstChild("HumanoidRootPart")
local StartTime
local LastCFrame = HumanoidRootPart.CFrame
local Points = { }
local Cooldown = false
UserInputService.InputBegan:Connect(function(Input,Processed)
if Processed or Cooldown then return end
if Input.KeyCode == Enum.KeyCode.Q then
print("player pressed Q")
HumanoidRootPart.Anchored = true
--for _,Point in ipairs(Points) do
-- HumanoidRootPart.CFrame = Point
-- task.wait(0.01)
--end
for i = #Points,1,-1 do
HumanoidRootPart.CFrame = Points[i]
print(Points[i])
task.wait(0.01)
end
Points = {}
Cooldown = true
HumanoidRootPart.Anchored = false
task.wait(5)
Cooldown = false
end
end)
while true do
task.wait(0.01)
if not StartTime then
StartTime = os.time()
end
if HumanoidRootPart.CFrame ~= LastCFrame then
LastCFrame = HumanoidRootPart.CFrame
table.insert(Points,HumanoidRootPart.CFrame)
end
if os.time() - StartTime >= 5 then
StartTime = os.time()
Points = {}
end
end
i think the error coming from here but i dont know how to fix it
for i = #Points,1,-1 do
HumanoidRootPart.CFrame = Points[i]
print(Points[i])
task.wait(0.01)
end