How would I rotate a tool by 90 degrees in x axis?

local broom = script.Parent
local unequipPrompt = broom.Head:WaitForChild('UnequipPrompt')
local equipPrompt = broom.Shaft:WaitForChild('EquipPrompt')
local ridePrompt = broom.Shaft:WaitForChild('RidePrompt')
local leavePrompt = broom.Shaft:WaitForChild('LeavePrompt')
local replicatedStorage = game:GetService('ReplicatedStorage')
local unequipBroom = replicatedStorage.Broom.UnequipBroom
local equipBroom = replicatedStorage.Broom.EquipBroom
local rideBroom = replicatedStorage.Broom.RideBroom
local leaveBroom = replicatedStorage.Broom.LeaveBroom
local remoteFunction = replicatedStorage.Broom.RemoteFunction

broom.Owner.Value = broom.Parent.Parent.Name

unequipPrompt.Triggered:Connect(function(player)
	local character = player.Character or player.CharacterAdded
	local humanoid = character:FindFirstChild('Humanoid')

	if humanoid then
		broom.Parent = game:GetService('Workspace')
		
		broom.Grip *= CFrame.Angles(math.pi * -0.5, 0, 0)
		
		for index, value in broom:GetChildren() do
			if value:IsA('Part') or value:IsA('UnionOperation') then
				value.Anchored = true
			end
		end
		
		unequipPrompt.Enabled = false
		equipPrompt.Enabled = true
		ridePrompt.Enabled = true
	end
end)

equipPrompt.Triggered:Connect(function(player)
	local character = player.Character or player.CharacterAdded
	local humanoid = character:FindFirstChild('Humanoid')
	
	for index, value in broom:GetChildren() do
		if value:IsA('Part') or value:IsA('UnionOperation') then
			value.Anchored = false
		end
	end
	
	if humanoid then
		broom.Parent = humanoid.Parent
		humanoid:EquipTool(broom)
		
		equipPrompt.Enabled = false
		ridePrompt.Enabled = false
		unequipPrompt.Enabled = true
	end
end)

ridePrompt.Triggered:Connect(function(player)
	local character = player.Character or player.CharacterAdded
	local humanoidRootPart = character:FindFirstChild('HumanoidRootPart')
	
	for index, value in broom:GetChildren() do
		if value:IsA('Part') or value:IsA('UnionOperation') then
			value.Anchored = false
		end
	end

	local weld = Instance.new('WeldConstraint')
	weld.Name = 'TemporaryWeld'
	weld.Parent = broom.Handle

	--broom.Handle.Position = 

	weld.Part0 = broom.Handle
	weld.Part1 = humanoidRootPart
	
	equipPrompt.Enabled = false
	ridePrompt.Enabled = false
	leavePrompt.Enabled = true
end)

leavePrompt.Triggered:Connect(function(player)
	local weld = broom.Handle:FindFirstChild('TemporaryWeld')
	if weld then
		weld:Destroy()
	end
	
	leavePrompt.Enabled = false
	equipPrompt.Enabled = true
	ridePrompt.Enabled = true
end)
1 Like

The problem Ian, is that you’re changing the grip and then parenting it to the workspace, the orientation in the workspace is different from the orientation of the grip. What is this tool for? Why do you want to turn it, I’m assuming you want to rotate it while you’re holding it, but if not you need to rotate the actual workspace orientation, you can do this using :PivotTo(). I’m pretty sure tool inherits from model, so it would look like this:

broom:SetPivot(broom:GetPivot() * CFrame.Angles(math.pi * -0.5, 0, 0))
1 Like

SetPivot is not a valid member of Tool “Workspace.Broom” - Server - Script:16

1 Like

Heh, I think I meant “PivotTo()”, I do this too much.

1 Like

image
It’s doing it again as if it wasn’t welded even though it is, no idea why this is happening

1 Like

Are you trying to use attachments for the weld constraint?

1 Like

No, I am not trying to use attachments.

1 Like