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

Body Position Script Works only once but not twice? (Parent Property of bodyposition is locked)

this is my script:

local bp = Instance.new("BodyPosition")
local model = script.Parent.Parent
local destination = model:FindFirstChild("D")
function onTouched(hit)
local torso = hit.Parent:WaitForChild("Humanoid").Parent:WaitForChild("Torso")
local h = hit.Parent:findFirstChild("Humanoid")
if h then
bp.Parent = torso
bp.Position = destination.Position
wait(5)
bp:Destroy()
end
end
script.Parent.Touched:Connect(onTouched)

what i am trying to do here is create a bodyposition into the player, so that it can make the player levitate to the destination block when touched. it works only once. If further information is needed, please contact me.

1 answer

✓ Accepted answer
local bp = Instance.new("BodyPosition")
local model = script.Parent.Parent
local destination = model:FindFirstChild("D")

Remove that from the top of your script and put that in your function, your deleting bp, it only creates it when the script runs.

1 comment

0

OMG THX SOO MUCH! (i feel stupid for not knowing that XD )

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