Hi, I have a jet pack tool that I scripted to disable when seated so that players don’t fly away in vehicles etc. when they have the jet pack equipped in a seat.
I have this in a local script in StarterPlayerScripts… although it works in studio and in game for me, on both pc and mobile, I have seen it not working for some players in same game with me who were playing both on pc and mobile. Some it worked for them and others it did not, and they were able to equip the jet pack and fly while seated.
I feel the issue lies both in it being a starterscript, maybe the script belongs in the tool? And the other issue might be how i point to the tool in the last few lines of code, maybe I need to point to the backpack instead? Oh and “Jetpack Local” is the local script inside the tool that I am disabling.
local UIS = game:GetService("UserInputService")
local Player = game.Players.LocalPlayer
local Tool = game.Workspace["Jet Pack"]
local Character = Player.Character or Player.CharacterAdded:wait()
local Seated = false
local Equipped = false
local mouse = Player:GetMouse()
if not Character or not Character.Parent then
Character = Player.CharacterAdded:Wait()
end
local Humanoid = Character:WaitForChild('Humanoid')
Humanoid.StateChanged:Connect(function(OldState, NewState)
if NewState == Enum.HumanoidStateType.Seated then
Seated = true
elseif NewState ~= Enum.HumanoidStateType.Seated then
Seated = false
end
end)
Tool.Equipped:Connect(function()
Equipped = true
end)
Tool.Unequipped:Connect(function()
Equipped = false
end)
UIS.InputBegan:Connect(function(Input, Processed)
if not Processed and Input.UserInputType == Enum.UserInputType.MouseButton1 and Equipped == true and Seated == true then
Tool["Jetpack Local"].Disabled = true
end
if not Processed and Input.UserInputType == Enum.UserInputType.MouseButton1 and Equipped == true and Seated == false then
Tool["Jetpack Local"].Disabled = false
end
if not Processed and Input.UserInputType == Enum.UserInputType.Touch and Equipped == true and Seated == true then
Tool["Jetpack Local"].Disabled = true
end
if not Processed and Input.UserInputType == Enum.UserInputType.Touch and Equipped == true and Seated == false then
Tool["Jetpack Local"].Disabled = false
end
end)