so the problem is that i need to make a jetpack mobile compability but im not familiar with mobile things pls help
here is the client script for the jetpack:
Client Code
local jetpackTool = script.Parent
local fuelGui = script:WaitForChild(“FuelGui”)
local fuelGuiClone
local fuelMax = 20
local fuelAmount = fuelMax
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local uis = game:GetService(“UserInputService”)
local spacePressedRE = jetpackTool:WaitForChild(“OnSpacePressed”)
local spaceReleasedRE = jetpackTool:WaitForChild(“OnSpaceReleased”)
local spaceHeld = false
local bodyForce = Instance.new(“BodyThrust”)
bodyForce.Force = Vector3.new(0, 0, 0)
bodyForce.Parent = jetpackTool.MainPart
jetpackTool.Equipped:Connect(function()
fuelGuiClone = fuelGui:Clone()
fuelGuiClone.Parent = plr.PlayerGui
uis.InputBegan:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Space then
spaceHeld = true
end
end)
uis.InputEnded:Connect(function(key)
if key.KeyCode == Enum.KeyCode.Space then
spaceHeld = false
end
end)
end)
jetpackTool.Unequipped:Connect(function()
spaceHeld = false
fuelGuiClone:Destroy()
end)
while wait() do
if plr.PlayerGui:FindFirstChild("FuelGui") then
local xScale = (1 / fuelMax) * fuelAmount
fuelGuiClone.BarBG.FuelBar.Size = UDim2.new(xScale, 0, 1, 0)
end
if spaceHeld and fuelAmount >= 0.03 then
spacePressedRE:FireServer()
bodyForce.Force = Vector3.new(0, 2700, 0)
fuelAmount = math.clamp(fuelAmount - 0.03, 0, fuelMax)
else
spaceReleasedRE:FireServer()
bodyForce.Force = Vector3.new(0, 0, 0)
fuelAmount = math.clamp(fuelAmount + 0.05, 0, fuelMax)
end
end
here is the ServerScript:
ServerScript
local jetpackTool = script.Parent
local spacePressedRE = jetpackTool:WaitForChild(“OnSpacePressed”)
local spaceReleasedRE = jetpackTool:WaitForChild(“OnSpaceReleased”)
jetpackTool.Equipped:Connect(function()
local upperTorso = jetpackTool.Parent:WaitForChild(“UpperTorso”)
local mainPart = jetpackTool:WaitForChild(“MainPart”)
local weld = Instance.new(“Weld”)
weld.C0 = CFrame.new(0, 0.2, -0.6)
weld.Part0 = mainPart
weld.Part1 = upperTorso
weld.Parent = mainPart
end)
spacePressedRE.OnServerEvent:Connect(function()
jetpackTool.ParticlesPartLeft.ParticleEmitter.Enabled = true
jetpackTool.ParticlesPartRight.ParticleEmitter.Enabled = true
end)
spaceReleasedRE.OnServerEvent:Connect(function()
jetpackTool.ParticlesPartLeft.ParticleEmitter.Enabled = false
jetpackTool.ParticlesPartRight.ParticleEmitter.Enabled = false
end)
here is the tool
Any ways to make this mobile compatible?
Thanks for Reading!