Below is my current code. It works when the section labeled "thrust in current direction" is removed. Any ideas why this section is preventing the above code from working? Can I get some help with the syntax of if / and statements?
--------------------------------------------------------------------------------------------------------------Header
local iT = script:GetCustomProperty("InitialThrust") --Modifyer on initial impulse to movement
local cT = script:GetCustomProperty("ContinuedThrust") --Modifyer on acceleration growth
local tP = script:GetCustomProperty("ThrustPower") --Modifyer on gravatational pull
local jetTimes = 0 --Time the Jetpack is running
local jetOn = false --Jetpack trigger
local jetBurst = iT / 100
local jetCarry = cT / 100
local jetPower = tP / 100
local targetPlayer = nil
--------------------------------------------------------------------------------------------------------------Standing Lift
function OnBindingPressed(whichPlayer, binding)
if (binding == "ability_extra_20") then
targetPlayer = whichPlayer
targetPlayer.gravityScale = -1 * jetPower
targetPlayer:AddImpulse(Vector3.UP * jetBurst)
jetOn = true
end
end
function Tick(deltaTime)
while jetOn == true do
jetCarry = jetCarry * jetTimes
targetPlayer:AddImpulse(Vector3.UP * targetPlayer.mass * jetCarry)
jetTimes = jetTimes + 0.5
Task.Wait(2.5)
end
end
--------------------------------------------------------------------------------------------------------------thrust in current direction
function OnBindingPressed(whichPlayer, binding)
if (binding == "ability_extra_20")
and (whichPlayer.isWalking == true) then
targetPlayer = whichPlayer
targetPlayer.gravityScale = 0.9
targetPlayer:AddImpulse(targetPlayer:GetVelocity() * jetBurst)
end
end
--------------------------------------------------------------------------------------------------------------Return
function OnBindingReleased(whichPlayer, binding)
if (binding == "ability_extra_20") then
whichPlayer.gravityScale = 1.5
jetOn = false
jetTimes = 0
end
end
--------------------------------------------------------------------------------------------------------------Footer
function OnPlayerJoined(player)
player.bindingPressedEvent:Connect(OnBindingPressed)
player.bindingReleasedEvent:Connect(OnBindingReleased)
end
Game.playerJoinedEvent:Connect(OnPlayerJoined)