I created a float script that when the player touch the brick, he will float, and when he isnt touching the brick, he will stop floating, but i dont know why he isnt working, what i did wrong?
player = hit.Parent
torso = player.Parent.Torso
human = player.Character.Humanoid
bin = script.Parent
Activated = false
function onTouched(hit)
local d = hit.Parent:GetChildren()
for i=1, #d do
Activated = true
if (bin.Touched == false) then
bin.Touched = true
for i, a in pairs(torso:GetChildren()) do
if a.Name == "FloatV" then
a:Remove()
end
end
bv = Instance.new("BodyVelocity")
bv.Name = "FloatV"
bv.maxForce = Vector3.new(0,math.huge,0)
bv.velocity = Vector3.new(0,0,0)
bv.Parent = torso
else bin.Touched = false
for i, v in pairs(torso:GetChildren()) do
if v.Name == "FloatV" then
v:Remove()
end
end
end
Activated = false
end
end
script.Parent.Touched:connect(onTouched)

1 comment
I would look into the TouchEnded event.