Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How would I fix the position of the Vector3?

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

✓ Accepted answer

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)

1 comment

0

Thank you this helped alot

This discussion is preserved as it was. New answers, comments, and votes are closed.