Changing a dummy's position using mouse.hit

I’m trying to make a script that changes a dummy’s position depending on where your mouse is at

local button = script.Parent.TextButton
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local dummy = game.ReplicatedStorage:WaitForChild("Minigun"):Clone()

	print("button pressed")
	dummy.Parent = game.Workspace
	mouse.TargetFilter = dummy
	while true do
		local pos = mouse.Hit.Position
		dummy.HumanoidRootPart.Position = pos

the problem is, changing the position of dummy’s humanoid root part does not move the entire body and I can’t think of an alternative way.

You use :SetPrimaryPartCFrame() and make sure the CFrame is

Can you tell me how I can implement :SetPrimaryPartCFrame() in my script?

Sure! So basically, wherever you would set the dummy’s HumanoidRootPart’s position, it wouldn’t move the character, just the RootPart. SetPrimaryPartCFrame() moves the entire character, based on the position of the HumanoidRootPart. The line:

dummy.HumanoidRootPart.Position = pos

can be changed to:


If you are inexperienced with them, I suggest reading up on CFrames here.

1 Like

Oh, I get it now, thanks for the help