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

how do i move the part without going up if it colided to another part?

Asked by
CjayPlyz 643 Moderation Voter
5 years ago
Edited 5 years ago
local clicked = 0

script.Parent.ClickDetector.MouseClick:Connect(function()
    if clicked == 0 then
        clicked = 1
        workspace.Move.Position = Vector3.new(-32, 7, 31.5)
    else
        clicked = 0
        workspace.Move.Position = Vector3.new(-32, 7, 32.5)
    end
end)

when it moves back.. instead of going back it goes on top of the part behind it

1 answer

Log in to vote
1
Answered by
fredfishy 833 Moderation Voter
5 years ago

You need to use CFrame instead of position.

local clicked = 0

script.Parent.ClickDetector.MouseClick:Connect(function()
    if clicked == 0 then
        clicked = 1
        workspace.Move.CFrame = CFrame.new(-32, 7, 31.5)
    else
        clicked = 0
        workspace.Move.CFrame = CFrame.new(-32, 7, 32.5)
    end
end)

Bare in mind that unless the brick you're moving is anchored then it'll just pop straight back out again thanks to physics.

0
thanks CjayPlyz 643 — 5y
Ad

Answer this question