Char = script.Parent.Parent
b = Instance.new("BodyPosition")
b.Parent = Char.Character.Torso
b.Position = Vector3.new(0,11.36,0)
b.MaxForce = Vector3.new(0,2300,0)
--this script works but the problem is I need it to only work when I touch a part In workspace What am i doing wrong?
✓ ANSWER ACCEPTED
why don't I stop floating?
1 answer
✓ Accepted answer
The Touched event will help you in your current condition. It loads the code that is found within the event once the specific Object is touched.
local BP = Instance.new("BodyPosition")
function FloatEnable(obj)
BP.Parent = obj:WaitForChild("Torso")
BP.Position = Vector3.new(0,11.36,0)
BP.MaxForce = Vector3.new(0,2300,0)
end
workspace.PART.Touched:connect(function(obj_hit)
if obj_hit.Parent:WaitForChild("Humanoid") then
FloatEnable(obj_hit.Parent)
else
print("Not Humanoid")
end
end)
workspace.PART.TouchEnded:connect(function()
BP:remove()
end)
This discussion is preserved as it was. New answers, comments, and votes are closed.
