I should clarify, the model CAN rotate past 90 degrees, however it never prints out any angle past 90 degrees. And never seems to be placed at an angle past 90 degrees.
When placing the model the angle of the primary part never exceeds 90 degrees with the angles getting weird between 90 and 270 degrees. Using print(math.deg(Y))
, you can see the part’s angle reaches near 0 degrees after being flipped 180 degrees on its yaw, and when placed, it’s placed at an angle of near 0 degrees instead of 180. But why?
https://gyazo.com/b551abb220b4d2ec019fa577a93a7547
Local Script
local function ChangePos(pos, norm, FurnitureLocal, TurnNum) -- Functions runs on mouse move
if FurnitureLocal ~= nil then
local endPos = pos + (norm * (FurnitureLocal.PrimaryPart.Size*.5))
local endAngle = CFrame.fromEulerAnglesXYZ(0, math.rad(TurnNum), 0)
FurnitureLocal:SetPrimaryPartCFrame(CFrame.new(endPos) * endAngle)
local X,Y,Z = FurnitureLocal.PrimaryPart.CFrame:ToEulerAnglesXYZ()
print(math.floor(math.deg(Y)))
end
end
mouse.Button1Down:Connect(function() -- Placing the item
if CreatedFurnitureLocal ~= nil and CreatedFurnitureLocal then
for i,v in pairs(FurnitureLocal:GetChildren()) do
if v.Name ~= "GridPart" then
v.CanCollide = true
end
end
local X,Y,Z = FurnitureLocal.PrimaryPart.CFrame:ToEulerAnglesXYZ()
print(math.floor(math.deg(Y)))
ReplicatedStorage.FurniturePlacement:FireServer(FurnitureLocal, FurnitureLocal.PrimaryPart.Position, Y)
CreatedFurnitureLocal = false
FurnitureLocal = nil
CurrentRot.Text = "Current Rotation: "
KeyPressed = false
end
end)
UserInputService.InputBegan:connect(function(InputObject, gameProcessedEvent) -- UIS
-- Rotate furniture
if InputObject.KeyCode == Enum.KeyCode.R and not gameProcessedEvent then
if FurnitureLocal ~= nil then
if tonumber(RotationTextboxValue.Text) then
if 0 < tonumber(RotationTextboxValue.Text) and tonumber(RotationTextboxValue.Text) <= 90 then
RotationValue = tonumber(RotationTextboxValue.Text)
TurnNum += RotationValue
if TurnNum == 360 then
TurnNum = 0
elseif TurnNum == -360 then
TurnNum = 0
end
CurrentRot.Text = "Current Rotation: " .. TurnNum
ChangePos(pos, norm, FurnitureLocal, TurnNum)
else
RotationTextboxValue.Text = "Enter an appropriate number"
end
else
RotationTextboxValue.Text = "Enter an appropriate number"
end
end
end
end)
Server Script
ReplicatedStorage.FurniturePlacement.OnServerEvent:Connect(function(player, Furniture, Position, Y)
for i, v in pairs(Furniture:GetChildren()) do
if v.Name ~= "GridPart" then
v.Transparency = 0
v.CanCollide = true
end
end
Furniture:SetPrimaryPartCFrame(CFrame.new(Position) * CFrame.fromEulerAnglesXYZ(0, Y, 0)) -- Copies the cframe from local script and replicates it on the server
end)