Why doesn't the model rotate?

Im making a placement system for my game put when i press “R” to Rotate the Building, it doesn’t rotate

code:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")

local Player = game.Players.LocalPlayer

local Building = script.Parent.Building.Value:Clone()

local function MovingSystem()

	local Rotation = 0

	for i, part in pairs(Building:GetDescendants()) do
		if part:isA("BasePart") then
			part.CanCollide = false
			part.Transparency = 0.5
		end
	end
	
	local function MoveToMouse()
		
		Building.Parent = workspace
		
		local Mouse = Player:GetMouse()
		
		while wait() do
			Mouse.TargetFilter = Building
			local ObjectPosition = CFrame.new(Mouse.Hit.Position.X, Mouse.Hit.Position.Y, Mouse.Hit.Position.Z)
			local ObjectAngles = CFrame.Angles(math.rad(0), math.rad(Rotation), math.rad(0))
			Building:PivotTo(ObjectPosition, ObjectAngles)
		end
	end
	
	UserInputService.InputBegan:Connect(function(input, gameProcessed)
		if input.KeyCode == Enum.KeyCode.R then
			Rotation += 90
		end
	end)
	
	MoveToMouse()
	
end

MovingSystem()

i tried to set math.rad(Rotation) to math.rad(90) put the Building Orientation was still 0,0,0

local ObjectAngles = CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))

i tried even change the rotation in the explorer put it became 0,0,0 immediately after

1 Like

Its Supposed to be Position * Rotation

Building:PivotTo(ObjectPosition * ObjectAngles)

PivotTo accepts one Argument which is a CFrame, You are Applying a CFrame with only the Position, and not the Rotation, so it would only Apply the Position.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.