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

How would I fix the position of the Vector3?

Asked by 6 years ago

Im trying to make this script work. It is FE but I dont see why it would matter because it is in a server script with click detector. This is what I have tried doing but searched online and dont see why it keeps going out of place.

local Open = false

script.Parent.ClickDetector.MouseClick:Connect(function()
    if Open == false then
        script.Parent.Size = Vector3.new(0.2, 0.2, 2.1)
        script.Parent.Position = Vector3.new(-312.8, 14.61, 467.85)
        Open = true
    else
        script.Parent.Size = Vector3.new(0.1, 3.6, 2.1)
        script.Parent.Position = Vector3.new(-312.75, 13.91, 467.85)
        Open = false
    end
end)

It works but the position keeps going a few studs on top or just dissapears.

1 answer

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
6 years ago

When you set the Position property of an Object with a Parent which is a descendant of the workspace, it will teleport up until it is no longer colliding with another object. Try setting the CFrame instead?

local Open = false

script.Parent.ClickDetector.MouseClick:Connect(function()
    if Open == false then
        script.Parent.Size = Vector3.new(0.2, 0.2, 2.1)
        script.Parent.CFrame = CFrame.new(-312.8, 14.61, 467.85)
        Open = true
    else
        script.Parent.Size = Vector3.new(0.1, 3.6, 2.1)
        script.Parent.CFrame = CFrame.new(-312.75, 13.91, 467.85)
        Open = false
    end
end)

0
Thank you this helped alot Sergiomontani10 236 — 6y
Ad

Answer this question