On mouse 1 pressed a remote event is fired and the server copies the position and angle of the furniture form the local script and sets the furnitures server cframe to that of the local cframe and angles.
I had looked this problem up and all the solutions suggested to use :SetPrimaryPartCFrame
, which I was already doing, what exactly am I missing here?
Local Script
mouse.Button1Down:Connect(function() -- Placing the item
if CreatedFurnitureLocal ~= nil and CreatedFurnitureLocal then
local X,Y,Z = FurnitureLocal.PrimaryPart.CFrame:ToEulerAnglesXYZ()
ReplicatedStorage.FurniturePlacement:FireServer(FurnitureLocal, FurnitureLocal.PrimaryPart.Position, Y)
CreatedFurnitureLocal = false
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
end
end
Furniture:SetPrimaryPartCFrame(CFrame.new(Position) * CFrame.fromEulerAnglesXYZ(0, math.rad(Y), 0))
end)
Model before remote event fired
Afterwards (both server and client side)