Hi Guys,
Basically I made a charged jump script; if the player holds Space
for 1 second then they jump twice as high.
I now want to add 5 seconds of flight when they reach the peak of the jump. I already have this part figured out, but I am unsure of how to successfully add the flying part of the code into the script.
(I basically want this from Shindo Life)
This is the code that I currently have; It is all working, I am just unsure of how to end it after 5 seconds:
Summary
local flying = false
local cam = workspace.CurrentCamera
humanoid:GetPropertyChangedSignal("JumpPower"):Connect(function(key)
if humanoid.JumpPower == 100 then
print("Power Change Acknowledged")
wait(.75)
print("Flying State Began")
flying = true
character.Animate.Disabled = true
-- ADD FLYING ANIMATION HERE
local bv = Instance.new("BodyVelocity", character.PrimaryPart)
bv.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
bv.Velocity = Vector3.new(0,0,0)
bv.Name = "FlightForce"
while wait() do
if flying then
character.PrimaryPart:FindFirstChild("FlightForce").Velocity = Vector3.new(0,0,0)
character.PrimaryPart:FindFirstChild("FlightForce").Velocity = cam.CFrame.LookVector * 50
end
end
end
end)
This is what it currently looks like; it just never ends:
https://gyazo.com/17231ee5547c165fe0d52d0f5e852b86