Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local uis = game:GetService("UserInputService")
- local suiton = false
- local ejected = false
- local used = false
- local flying=false
- local toggle = false
- local waiting = false
- local waiting2 = false
- local hassuit = false
- local used2 = false
- script.Done.Changed:Connect(function()
- if script.Done.Value == true then
- used = true
- hassuit = true
- suiton = true
- script.Suiton.Value = true
- end
- end)
- --Eject/PutOnSuit
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.N and not gameProcessedEvent then
- if waiting2 == false then
- if suiton == true then
- script.Suiton.Value = false
- waiting2 = true
- script.Parent.Remotes.Eject:FireServer()
- ejected = true
- suiton = false
- wait(6)
- waiting2 = false
- else if ejected == true then
- suiton = true
- script.Suiton.Value = true
- script.Parent.Remotes.EquipSuit:FireServer()
- wait(6)
- waiting2 = false
- end
- end
- end
- end
- end
- end)
- --ToggleMask
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.M and not gameProcessedEvent then
- if suiton == true then
- if waiting == false then
- if toggle == false then
- waiting = true
- script.Parent.Remotes.ToggleMaskUp:FireServer()
- wait(0.2)
- toggle = true
- print("e")
- wait(2)
- waiting = false
- else
- if waiting == false then
- waiting = true
- print("e2")
- script.Parent.Remotes.ToggleMaskDown:FireServer()
- wait(0.2)
- toggle = false
- wait(2)
- waiting = false
- end
- end
- end
- end
- end
- end
- end)
- local CoolDownRight = false
- --Right Repulsor
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
- if suiton == true then
- if CoolDownRight == false then
- CoolDownRight = true
- local mouse = game.Players.LocalPlayer:GetMouse()
- script.Parent.Remotes.RightRepulsorSound:FireServer()
- wait(1.2)
- script.Parent.Remotes.ChestRepulsorShoot:FireServer(mouse.Hit)
- wait(2.8)
- CoolDownRight = false
- end
- end
- end
- end
- end)
- local CoolDownLeft = false
- --Left Repulsor
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.Q and not gameProcessedEvent then
- if suiton == true then
- if CoolDownLeft == false then
- CoolDownLeft = true
- local mouse = game.Players.LocalPlayer:GetMouse()
- script.Parent.Remotes.LeftRepulsorSound:FireServer()
- wait(1.2)
- script.Parent.Remotes.LeftRepulsorShoot:FireServer(mouse.Hit)
- wait(2.8)
- CoolDownLeft = false
- end
- end
- end
- end
- end)
- local CoolDownChest = false
- --Chest Repulsor
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.R and not gameProcessedEvent then
- if suiton == true then
- if CoolDownChest == false then
- CoolDownChest = true
- local mouse = game.Players.LocalPlayer:GetMouse()
- script.Parent.Remotes.ChestRepulsorSound:FireServer()
- wait(1.481)
- script.Parent.Remotes.ChestRepulsorShoot:FireServer(mouse.Hit)
- wait(5)
- CoolDownChest = false
- end
- end
- end
- end
- end)
- --Explode Suit
- uis.InputBegan:Connect(function(input,gameProcessedEvent)
- if input.UserInputType == Enum.UserInputType.Keyboard then
- if input.KeyCode == Enum.KeyCode.P and not gameProcessedEvent then
- if suiton == false then
- if hassuit == true then
- if ejected == true then
- if used2 == false then
- script.Parent.Remotes.ExplodeSuit:FireServer()
- used2 = true
- wait(10)
- script.Suiton.Value = false
- suiton = false
- hassuit = false
- used = false
- waiting = false
- waiting2 = false
- ejected = false
- used2 = false
- end
- end
- end
- end
- end
- end
- end)
- script.Suiton.Changed:Connect(function()
- if suiton == true then
- sp=script
- plr=game.Players.LocalPlayer
- mouse=plr:GetMouse()
- local speed=5
- local topspeed=90
- local rate=math.huge/math.huge
- local inertia=1-(speed/topspeed)
- local debris=game:GetService("Debris")
- local controls={forward=0,backward=0,left=0,right=0}
- local momentum=Vector3.new(0,0,0)
- local lastmomentum=Vector3.new(0,0,0)
- local totalmomentum=0
- local tilt=0
- local lasttilt=0
- local anim=script:WaitForChild("IdleANIM_Fly")
- local anim2=script:WaitForChild("FowardANIM_Fly")
- local hum = plr.Character:WaitForChild("Humanoid")
- local Forward = hum:LoadAnimation(anim2)
- function RemoveFlyStuff()
- if plr and plr.Character then
- local torso=plr.Character:FindFirstChild("UpperTorso")
- if torso~=nil then
- for _,v in pairs(torso:GetChildren()) do
- if v and (v.Name=="FlightGyro" or v.Name=="FlightVelocity") then
- v:remove()
- end
- end
- end
- end
- if flyanim~=nil then
- flyanim:Stop()
- end
- end
- function fly() --(de)activate fly mode
- flying=not flying
- RemoveFlyStuff()
- if flying then
- if plr and plr.Character then
- local torso=plr.Character:FindFirstChild("UpperTorso")
- local humanoid=plr.Character:FindFirstChild("Humanoid")
- if torso and humanoid and humanoid.Health>0 then
- momentum=torso.Velocity+(torso.CFrame.lookVector*10)+Vector3.new(0,10,0)
- plr.Character.Humanoid.PlatformStand = true
- plr.Character.Sounds.StartFly:Play()
- plr.Character.Sounds.Inair:Play()
- script.Flying.Value = true
- script.Parent.Remotes.FlyEffects:FireServer()
- local gyro=Instance.new("BodyGyro")
- gyro.Name="FlightGyro"
- gyro.P=10^4
- gyro.maxTorque=Vector3.new(gyro.P,gyro.P,gyro.P)
- gyro.cframe=torso.CFrame
- gyro.Parent=torso
- velocity=Instance.new("BodyVelocity")
- velocity.Name="FlightVelocity"
- velocity.velocity=Vector3.new(0,0,0)
- velocity.P=10^3
- velocity.maxForce=Vector3.new(1,1,1)*(10^6)
- velocity.Parent=torso
- flyanim=humanoid:LoadAnimation(anim)
- if flyanim~=nil then
- flyanim:Stop()
- end
- if flyanim then
- flyanim:Play()
- end
- while flying and torso and humanoid and humanoid.Health>0 do
- local movement=game.Workspace.CurrentCamera.CoordinateFrame:vectorToWorldSpace(Vector3.new(controls.left+controls.right,math.abs(controls.forward)*.2,controls.forward+controls.backward))*speed
- momentum=(momentum*inertia)+movement
- totalmomentum=momentum.magnitude
- if totalmomentum>topspeed then
- totalmomentum=topspeed
- end
- local tilt=((momentum*Vector3.new(1,0,1)).unit:Cross(((lastmomentum*Vector3.new(1,0,1)).unit))).y
- local tstilt=tostring(tilt)
- if tstilt=="-1.#IND" or tstilt=="1.#IND" or tilt==math.huge or tilt==-math.huge or tstilt==tostring(0/0) then
- tilt=0
- end
- local abstilt=math.abs(tilt)
- if abstilt>.06 or abstilt<.0001 then
- if math.abs(lasttilt)>.0001 then
- tilt=lasttilt*.9
- else
- tilt=0
- end
- else
- tilt=(lasttilt*.77)+(tilt*.25) --weighted average
- end
- lasttilt=tilt
- if totalmomentum<.5 then
- momentum=Vector3.new(0,0,0)
- totalmomentum=0
- gyro.cframe=game.Workspace.CurrentCamera.CoordinateFrame
- else
- gyro.cframe=CFrame.new(Vector3.new(0,0,0),momentum)*CFrame.Angles(0,0,tilt*(-20))*CFrame.Angles(math.pi*(-.5)*(totalmomentum/topspeed),0,0)
- end
- velocity.velocity=momentum
- lastmomentum=momentum
- wait(rate)
- end
- RemoveFlyStuff()
- flying=false
- script.Flying.Value = false
- plr.Character.Humanoid.PlatformStand = false
- plr.Character.Sounds.Inair:Stop()
- script.Parent.Remotes.RemoveFlyEffects:FireServer()
- end
- end
- end
- end
- script.Flying.Changed:Connect(function()
- if script.Flying.Value == false then
- RemoveFlyStuff()
- flying=false
- script.Flying.Value = false
- plr.Character.Humanoid.PlatformStand = false
- while flying == false do
- flyanim:Stop()
- Forward:Stop()
- script.Parent.Remotes.RemoveFlyEffects:FireServer()
- wait()
- end
- end
- end)
- local IsFlying = false
- while true do
- wait()
- if plr and plr.Character and plr.Character.Parent==game.Workspace then
- break
- end
- end
- mouse.KeyDown:connect(function(Key)
- if Key == "f" then
- mouse.KeyDown:connect(function(key2)
- local key=string.byte(key2)
- if key==32 then --Space bar
- IsFlying = not IsFlying
- elseif key==string.byte("w") or key==17 then
- controls.forward=-1
- if flying == true then
- script.Parent.Remotes.FlyEffects2:FireServer()
- Forward:Play()
- end
- elseif key==string.byte("a") or key==20 then
- controls.left=-1
- if flying == true then
- script.Parent.Remotes.FlyEffects2:FireServer()
- Forward:Play()
- end
- elseif key==string.byte("s") or key==18 then
- controls.backward=1
- if flying == true then
- script.Parent.Remotes.FlyEffects2:FireServer()
- Forward:Play()
- end
- elseif key==string.byte("d") or key==19 then
- controls.right=1
- if flying == true then
- script.Parent.Remotes.FlyEffects2:FireServer()
- Forward:Play()
- end
- end
- end)
- mouse.KeyUp:connect(function(key2)
- local key=string.byte(key2)
- if key==string.byte("w") or key==17 then
- controls.forward=0
- Forward:Stop()
- script.Parent.Remotes.FlyEffects:FireServer()
- elseif key==string.byte("a") or key==20 then
- controls.left=0
- Forward:Stop()
- script.Parent.Remotes.FlyEffects:FireServer()
- elseif key==string.byte("s") or key==18 then
- controls.backward=0
- Forward:Stop()
- script.Parent.Remotes.FlyEffects:FireServer()
- elseif key==string.byte("d") or key==19 then
- controls.right=0
- Forward:Stop()
- script.Parent.Remotes.FlyEffects:FireServer()
- end
- end)
- delay(0,function()
- fly()
- IsFlying = true
- end)
- end
- end)
- mouse.KeyDown:connect(function(Key)
- if Key == "f" then
- if flying then
- RemoveFlyStuff()
- IsFlying = false
- plr.Character.Humanoid.PlatformStand = false
- end
- end
- end)
- while wait() do
- if flying == false then
- flyanim:Stop()
- end
- end
- end
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement