Why is this part of my script erroring?

Im trying to make it so a cloned object can go telaport to the humanoid root part, its getting an error though;

  22:52:38.793  Unable to cast Instance to CoordinateFrame  -  Client - Abilitys:27
  22:52:38.793  Stack Begin  -  Studio
  22:52:38.793  Script 'Workspace.NubblyFry.Dandilion Collecter.Abilitys', Line 27 - function SummonAbility  -  Studio - Abilitys:27
  22:52:38.793  Script 'Workspace.NubblyFry.Dandilion Collecter.Abilitys', Line 40  -  Studio - Abilitys:40
  22:52:38.793  Stack End  -  Studio
FXClone.Position = FXClone:PivotTo(script.Parent.Parent:WaitForChild("HumanoidRootPart"))

Script

local Tool = script.Parent

local Ability1Combo = 0

local RS = game:GetService("ReplicatedStorage")

local AbilityFX2 = RS:WaitForChild("AbilityFX2")

local Debounce = false

Tool.Activated:Connect(function()
	if Debounce == false then
		task.wait(1)
		Ability1Combo = Ability1Combo + 1
	else
		if Debounce ~= false then
			print("Ability 2 Is On Cooldown...")
		end
	end
end)

local function SummonAbility()
	Debounce = true
	print("The Ability Flower Power Has Been Summoned")
	local FXClone = AbilityFX2:Clone()
	FXClone.Parent = workspace
	FXClone.Position = FXClone:PivotTo(script.Parent.Parent:WaitForChild("HumanoidRootPart"))
	task.wait(30)
	Ability1Combo = 0
	Debounce = false
end

while true do
	task.wait()
	if Ability1Combo == 3 then
		Ability1Combo = 0
		
		task.wait(0.5)

		SummonAbility()
	end
end


while true do
	task.wait(0.5)
	print(Ability1Combo)
end

The PivotTo method takes a CFrame object as an argument, not an actual instance.

Try this:

FXClone.Position = FXClone:PivotTo(script.Parent.Parent:WaitForChild("HumanoidRootPart").CFrame)

Side note, it also doesn’t return anything, so it should throw an error attempting to set the position of FXClone to it. Just call it directly.

1 Like

It works but, the Orientation is strange.

Reviving dead topic, Im getting a similar issue however PivotTo is not throwing any issues. My slab of code goes like this, under a RenderStepped. renderloop() works just fine and doesnt manipulate anything using PivotTo and everything in PivotTo breaks. Ive done multiple posts on the topic and no one has a clue, I saw this and thought this might be a case of help. Thanks.

    local char = Player.Character
	riggy = rig:Clone() print("rig cloned")
	riggy.Parent = CurrentCamera
	riggy.PrimaryPart = riggy.HumanoidRootPart

        loop = RunService.RenderStepped:Connect(function()
            if riggy.PrimaryPart == riggy.HumanoidRootPart then
			    riggy:PivotTo(CurrentCamera.CFrame * module.CameraOffset * WalkingOffset)
		    end
    renderloop()
end)

You should take this to dms, as its bumping a 1m old post.

1 Like