I want a seat that makes the player jump if the player does not have the correct tool. How would I do that?
You want to check if they have the tool in their inventory or if it’s equipped?
if they have the tool in their inventory.
This script can be thrown into the seat
script.Parent:GetPropertyChangedSignal('Occupant'):Connect(function()
local humanoid = script.Parent.Occupant
if humanoid then
local char = humanoid.Parent
local player = game.Players:GetPlayerFromCharacter(char)
if player.Backpack:FindFirstChild('Tool') then -- 'Tool' is your tool name
print('allowed')
else
humanoid.Jump = true
print('not allowed')
end
end
end)
;-; so much better then the one I posted.
I noticed that, yours was a little overcomplicated so I created a simplified version lol
jumping bit isn’t working for me I’m afraid, it prints “allowed” or “not allowed” but it’s not having the player jump
Hi!
@StraightScared your script is actually more accurate, because the tool moves out of player’s backpack when they hold it, and you’ve covered that case. I took your script and made some small changes. Apparently, you have to turn off humanoid.Sit before triggering jump, and even before that, wait for a short time interval, likely for SeatWeld to create, in order to jump.
EDIT
Replace “MyTool” with the name of your tool.
@StraightScared I know that your choices don’t concern me, but I think it is my place to say that you didn’t have to remove your post, because it certainly helped!
local Players = game:GetService("Players")
local seat = script.Parent
local function CheckForTool(character)
local player = Players:GetPlayerFromCharacter(character)
local backpack = player.Backpack:GetChildren()
-- check for the tool in workspace
if character:FindFirstChild("MyTool") then return true end
-- check for it in backpack
for i, v in pairs(backpack) do
if (v:IsA("Tool") and v.Name == "MyTool") then
return true
end
end
return false
end
seat:GetPropertyChangedSignal("Occupant"):Connect(function()
if (not seat.Occupant) then return; end
local character = seat.Occupant.Parent
local access = CheckForTool(character)
if (not access) then
local humanoid = character:WaitForChild("Humanoid")
if (humanoid) then
wait(0.1)
humanoid.Sit = false
humanoid.Jump = true
end
end
end)