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

Block teleports on top of me, need help with vector3 teleport buttons?

this is what i want: a block room where if you touch a reset button, the blocks reset position (like a regen car) this is my script: (reh is block name)

part = script.Parent

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('reh') then
	part.Position = Vector3.new(position i want here)
	end
end)

but everytime i touch it, it teleports on top of me.. ?

2 answers

When you use Position, it will prevent collision from 2 objects. The reason it's teleporting on top of you is because the game is preventing you from putting the block inside you. A much more reliable ray to set an objects position is CFrame, or coordinate frame. I edited your code to use CFrame instead:

part = script.Parent

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('reh') then
    part.CFrame = CFrame.new(position i want here)
    end
end)

anchor it?

part = script.Parent
part.Anchored = true

script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild('reh') then
    part.Position = Vector3.new(position i want here)
    end
end)

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