On the MouseDown event, when i print out the CFrames and the Rotation, it’s always 0,0,0. Am I missing something?
The Rotation applies to the actual model, but when i print the values it’s wrong.
toSpawn is an Instance: Model
mouse.Button1Down:Connect(function()
if toSpawn then
assert(toSpawn:IsA("Model"))
print(toSpawn:GetPivot())
print(toSpawn.PrimaryPart.CFrame)
print(toSpawn.PrimaryPart.Rotation)
ReplicatedStorage.Events.Place:FireServer(toSpawn.Name, toSpawn:GetPivot())
destroyPlaceholder()
end
end)
You should be able to print it on the server I would think but if you can’t i’d try rotating the model outside of the script and seeing if it changes, otherwise no harm in having the server rotate it to 0,0,0 or client do it just so it can be 100% accurate at 0,0,0
local function rotateModel(degrees)
assert(toSpawn:IsA("Model"))
local primaryPart = toSpawn.PrimaryPart
if primaryPart then
primaryPart.CFrame = primaryPart.CFrame * CFrame.Angles(0, math.rad(degrees), 0)
end
end
uis.InputBegan:Connect(function(input, proc)
if proc then return end
if input.KeyCode == Enum.KeyCode.R then
if toSpawn then
rotateModel(45)
end
end
if input.KeyCode == Enum.KeyCode.T then
if toSpawn then
rotateModel(-45)
end
end
end)
Try doing Model:SetPrimaryPartCFrame(). I think you’re just moving the primaryPart around by itself, right now.
Also, you should be a little more consistent with the instances you’re checking. Instead of switching from primarypart to model, why not stick with the primarypart?
i was using assertion for code suggestions, i will remove them afterwards, thanks
also can you help me on how to use the getboundingbox function? sorry, i’ve never used it.
mouse.Button1Down:Connect(function()
if toSpawn then
local cf = toSpawn:GetPivot()
print(cf)
ReplicatedStorage.Events.Place:FireServer(toSpawn.Name, cf)
destroyPlaceholder()
end
end)