Unable to assign property CFrame. CoordinateFrame expected, got nil

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
1 Like

Greetings!
I think you might have an issue with your Points table, the error says that the current i (index) in the table Points return nil and a CoordinateFrame is required.
Try to add conditions, like if Points[i] exists, if not continue.
Let me know if I helped you!

1 Like
	for i = #Points,1,-1 do
		if Points[i] then
			HumanoidRootPart.CFrame = Points[i]
			print(Points[i])
		end
		task.wait(0.01)

	end

well yeah just a little if statement helped Thanks ;D :heart:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.