SetPrimaryPartCFrame() only works once

Hi, I don’t know why but my SetPrimaryPartCFrame() only works once… I don’t know why. Do you have a solution? I don’t have any errors in my output

local plr = game.Players.LocalPlayer

script.Parent.Activated:Connect(function()
	
	script.HitBox:SetPrimaryPartCFrame(CFrame.new(Vector3.new(workspace[plr.Name].HumanoidRootPart.Position)))
	
end)

I’m not really sure what your goal is by teleporting a hitbox, but your code has a lot of unnecessary stuff.

Here it is cleaned up a bit:

local plr = game.Players.LocalPlayer
script.Parent.Activated:Connect(function()
	script.HitBox:SetPrimaryPartCFrame(plr.Character.HumanoidRootPart.CFrame)
end)
1 Like

Thanks for the cleaning!!!

Try putting in a print statement to make sure that the function is running at all. (It should trigger but I would still try to be sure.)

1 Like

it’s ok! the problem was solved! but thank you as well for your help!

1 Like