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

Made a script using vector3 (Not working properly?) [Easy fix]

So I made this simple script that will teleport a block using vector 3

It worked well, but i have a problem.

If you stand in that position the block will spawn on top of you or on top of a different part.

Any way to fix this??

script.Parent.ClickDetector.MouseClick:Connect(function()
	local Block = game.ServerStorage.Block
	Block.Parent = game.Workspace
	Block.Position = Vector3.new(0.8, 0.5, 12.76)
	wait(1)
	Block:Destroy()
end)


1 answer

✓ Accepted answer

You can set the CFrame instead, Vector3 will always round off the position till its not touching anything

script.Parent.ClickDetector.MouseClick:Connect(function()
    local Block = game.ServerStorage.Block
    Block.Parent = game.Workspace
    Block.CFrame = CFrame.new(0.8, 0.5, 12.76)
    wait(1)
    Block:Destroy()
end)


3 comments

0

Thanks, worked very well. But is there any way to make the part go back to ServerStorage after being Destroyed?

0

No if you Destroy an object you cannot access it anymore, if you want to temporarily "Destroy" an object you can set the parent to nil, or in your case you want it to go back to serverStorage just set the parent of the Block to ServerStorage

0

Ok thanks, that worked!

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