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

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
0
Answered by
aazkao 787 Moderation Voter
5 years ago

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)


0
Thanks, worked very well. But is there any way to make the part go back to ServerStorage after being Destroyed? Vibesgus 35 — 5y
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 aazkao 787 — 5y
0
Ok thanks, that worked! Vibesgus 35 — 5y
Ad

Answer this question