Jetpack Not Woking

I’m using a jetpack script and it only works when you initially launch the game:

You can see me flying here. However when I equip another jetpack. I can only “jump up”, but not fly :

Lastly, here is the script it uses, don't worry about the remote events, they're only for particles (it's pretty long
--services
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local CAS = game:GetService("ContextActionService")

--player vars
local player = Players.LocalPlayer
local char = script.Parent.Parent
local hum = char:WaitForChild("Humanoid")
local hrp = char.PrimaryPart
local animator = hum:WaitForChild("Animator")
local anim = script:WaitForChild("Animation")
local animTrack = animator:LoadAnimation(anim)

--sounds
local thrustSound = script:WaitForChild("Thrust")
local boostSound = script:WaitForChild("SpeedBoost")

--remote functions / events
local performActionRF = ReplicatedStorage.Jetpack:WaitForChild("PerformAction")
local toggleParticles = ReplicatedStorage.Jetpack:WaitForChild("ToggleParticles")

--body movers
local bodyGyro = Instance.new("BodyGyro")
bodyGyro.P = 10000
bodyGyro.MaxTorque = Vector3.one * math.huge
bodyGyro.CFrame = hrp.CFrame

local bodyVelocity = Instance.new("BodyVelocity")
bodyVelocity.P = 5000
bodyVelocity.MaxForce = Vector3.zero
bodyVelocity.Parent = hrp

--the table containing the particle emitters
local emitters = {}
local speedBoostEmitters = {}

for _, emitter:ParticleEmitter in pairs(script.Parent:GetDescendants()) do
	if emitter:IsA("ParticleEmitter") then
		if emitter.Name == "Speed" then
			table.insert(speedBoostEmitters, emitter)
		else
			table.insert(emitters, emitter)
		end
		
	end
end

--vars
local speed = 35
local maxSpeed = 50
local plrSpeed = speed
--the flight and boost durations
local boostDuration = 5
local flightDuration = 15
--debounces
local lastBoost = tick()
local lastFlight = tick()
--bools
local isFlying = false
local isBoosting = false

local function activateFlight(actionName:string, inputState, inputObject:EnumItem)
	
	if inputState == Enum.UserInputState.End or not performActionRF:InvokeServer(1, emitters) then return end
	
	isFlying = true
	--have the player jump
	bodyVelocity.MaxForce = Vector3.zero
	hum:ChangeState(Enum.HumanoidStateType.Jumping)
	wait(.5)
	--toggle the particles
	toggleParticles:FireServer(emitters, true)
	--toggle the body velocity
	bodyVelocity.MaxForce = Vector3.one * math.huge
	--play the anim
	animTrack.Priority = Enum.AnimationPriority.Action
	animTrack:Play()
	--play the thrust sound
	if not thrustSound.Playing then
		thrustSound:Play()
	end
	
	--set the debounce
	lastFlight = tick()
	
	
	coroutine.wrap(function()
		repeat wait() until tick() - lastFlight > flightDuration or not isFlying
		--stop the anim
		animTrack:Stop()
		--stop the thrust sound
		thrustSound:Stop()
		--toggle the body velocity
		bodyVelocity.MaxForce = Vector3.zero
		--toggle the particles
		toggleParticles:FireServer(emitters, false)
		isFlying = false
	end)()
end

local function boostPlayer(actionName:string, inputState:EnumItem, inputObject:EnumItem)
	
	if inputState == Enum.UserInputState.End or not performActionRF:InvokeServer(1, emitters) then return end
	
	isBoosting = true
	--increase the player's speed
	plrSpeed = maxSpeed
	--set the walkspeed
	hum.WalkSpeed = maxSpeed
	--set the debounce
	lastBoost = tick()
	--play the boost sound
	if not boostSound.Playing then
		boostSound:Play()
	end
	
	
	toggleParticles:FireServer(speedBoostEmitters, true)
	
	coroutine.wrap(function()
		repeat wait() until tick() - lastBoost > boostDuration
		--reset the speed
		plrSpeed = speed
		--set the walkspeed
		hum.WalkSpeed = 35
		--hide the particles
		toggleParticles:FireServer(speedBoostEmitters, false)
		isBoosting = false
		boostSound:Stop()
	end)()
	
end

--connections
RunService.RenderStepped:Connect(function()
	local GetMoveVector = require(player:WaitForChild("PlayerScripts").PlayerModule:WaitForChild("ControlModule")):GetMoveVector()
	--set the speed of the bodyVelocity
	bodyVelocity.velocity = (game.Workspace.CurrentCamera.CoordinateFrame.lookVector * (-GetMoveVector.Z) + ((game.Workspace.CurrentCamera.CoordinateFrame * CFrame.new(GetMoveVector.X,(GetMoveVector.Z)*.2,0).Position) - game.Workspace.CurrentCamera.CFrame.p))*plrSpeed 
end)

UIS.JumpRequest:Connect(function()
	if isFlying then
		isFlying = false
	end
end)

--bind actions
CAS:BindAction("ToggleFlight", activateFlight, true, Enum.KeyCode.X)
CAS:SetTitle("ToggleFlight", "Fly")
CAS:SetPosition("ToggleFlight", UDim2.fromScale(0.5,0))

CAS:BindAction("Boost", boostPlayer, true, Enum.KeyCode.LeftShift)
CAS:SetTitle("Boost", "Boost")
CAS:SetPosition("Boost", UDim2.fromScale(0.5, .25))

The flying part just suddenly stops working. One solution I am yet to try, this is also a bug, that when you respawn you don’t have your jetpack on your back. Maybe if I add a script to add it back it’ll work and also respawn the character when a new jetpack is equipped.

If the scripts need to work each time the player’s character respawns/reloads etc. then move the scripts from StarterPlayerScripts to StarterCharacterScripts instead.

You mean when the player equips a new jetpack?