Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do I weld a part and change its rotation?

I made a script where a part welds (motor6d) to the player's hand when you click a brick. I was wondering how am I able to rotate the part so that is welded to a certain angle

local function OnClick(player)
	print(player.Name)
	local char = game.Workspace:FindFirstChild(player.Name)
	local handle = game.ServerStorage.Handle:Clone()
	handle.Parent = workspace
	
	local Motor6D = Instance.new("Motor6D",char.RightHand)
	Motor6D.Name = "HandleMotor6D"
	Motor6D.Part0 = char.RightHand
	Motor6D.Part1 = handle
end

	                           
script.Parent.ClickDetector.MouseClick:connect(OnClick)

1 answer

✓ Accepted answer
local function OnClick(player)
    print(player.Name)
    local char = game.Workspace:FindFirstChild(player.Name)
    local handle = game.ServerStorage.Handle:Clone()
    handle.Parent = workspace

    local Motor6D = Instance.new("Motor6D",char.RightHand)
    Motor6D.Name = "HandleMotor6D"
    Motor6D.Part0 = char.RightHand
    Motor6D.Part1 = handle
    
    --to change the CFrame (position and rotation)
    Motor6D.C1 = CFrame.Angels(90,0,0)

    --because you are using motor6d you can use the transform property
    Motor6D.Transform = CFrame.new()
end


script.Parent.ClickDetector.MouseClick:connect(OnClick)

info about motor6d

info on the transform property

This discussion is preserved as it was. New answers, comments, and votes are closed.