Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why does this part's rotation reset?

Asked by 5 years ago
Edited 5 years ago

Please read before looking at code. Yes, I am aware that I am not updating the part's position on the server side. That's because I haven't done it yet. I can move parts fine but the problem comes when I rotate a part. Let's say I duplicate the parts then set one of the part's Y orientation value to 180, when I play and click the part that is rotated and then move it, it resets the part's rotation back to (0,0,0). Why is that? (it does this both ingame and in studio)

--Server Script
CurrentlyEditing = false
Model = script.Parent
PrimaryPart = Model.PrimaryPart

function Clicked(player)
    if CurrentlyEditing == false then
        CurrentlyEditing = true
        wait()
    else
        CurrentlyEditing = false
        wait()
    end
    game:GetService("ReplicatedStorage").PartEdit.Click:FireClient(player, CurrentlyEditing, Model)
end

function ChangePartProperties()
    if CurrentlyEditing == true then

    end
end

script.Parent.ClickDetector.MouseClick:connect(Clicked)
game:GetService("ReplicatedStorage").PartEdit.UpdatePartProperties.OnServerEvent:connect(ChangePartProperties)

--Local Script
Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
Editing = nil

function MovePart(CurrentlyEditing, Model)
    Editing = CurrentlyEditing
    print(CurrentlyEditing)
    while Editing == true do
        local MousePosX = RoundUp(Mouse.Hit.p.x)
        local MousePosZ = RoundUp(Mouse.Hit.p.z)
        Model:SetPrimaryPartCFrame(CFrame.new(MousePosX, Model.PrimaryPart.CFrame.p.y, MousePosZ))
        wait()
    end
end

function RoundUp(number)
    number = number-(number%0.5)
    return number
end

function UpdateProperties()
    game:GetService("ReplicatedStorage").PartEdit.UpdatePartProperties:FireServer()
end

game:GetService("ReplicatedStorage").PartEdit.Click.OnClientEvent:connect(MovePart)
0
Your code is cut off. Make a few more variables. Perhaps your problem is in the cut-off code. User#19524 175 — 5y

Answer this question