I have a tank that I want to hover, but I'm having a spot of trouble getting it to. The script manages to get ALL THE WAY THROUGH, but somehow the tank keeps travelling straight up instead of staying. Any ideas?
Base = script.Parent.MainPart
Detector = script.Parent.Detector
HoverToggle = true
Weight = 0
for i,v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then
Weight = Weight + v:GetMass()
end
end
_G["HoverOn"] = function ()
HoverToggle = true
end
_G["HoverOff"] = function ()
HoverToggle = false
end
Detector.Touched:connect(function (hit)
print("1")
if not HoverToggle == true then return end
print("2")
if hit.Parent == script.Parent then return end
print("3")
local AltOfOtherBrick = hit.Position.Y
local AltOfHoverBase = Base.Position.Y
local AltDifference = AltOfHoverBase - AltOfOtherBrick
print("calc")
print("At Calc it was"..AltDifference)
if AltDifference > 3 then
print("doing")
Base.BodyForce.force = Vector3.new(0, 196.2, 0)*(Weight*2)
repeat
wait()
AltOfOtherBrick = hit.Position.Y
AltOfHoverBase = Base.Position.Y
AltDifference = AltOfHoverBase - AltOfOtherBrick
print(AltDifference)
until AltDifference >= 3.1
Base.Anchored = true
Base.BodyForce.force = Vector3.new(0,Weight*192.8,0)
wait()
Base.Anchored = false
print('ogm')
print("win")
end
end)
