So, I’ve been making a game recently and I was wondering how I could make it so when a player sits on a select seat they cannot jump out of it, without having to make it so there is server-wide anti-jump
I’m looking for a script that can do this for me, and a brief explanation on how to do it, etc.
I have searched YouTube and I could only find ones that would disable jumping overall, which I do not want. After searching the dev forum, I was a bit confused so here I am.
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Changed:connect(function(Property)
if Property == "Jump" then
Humanoid.Jump = false
end
end)
This is my current script but I only want your jump to be disabled when you enter a select seat.
I’m pretty sure this activates whenever a Character jumps, which will also return back as true
You could do Humanoid.JumpPower = 0 for a temporary solution maybe?
But the thing is I want the player to be able to jump when they are walking around, but when they get into a specific seat I don’t want them to be able to get out of it.
Well you can set Humanoid.JumpPower to 0 once they sit in that specific seat. If you don’t know how to check when a player sits down and who that player is, you can do it by checking for the Weld which is created between a Character and a Player
script.Parent.ChildAdded:Connect(function(child)
if child:IsA("Weld") and game:GetService("Players"):GetPlayerFromCharacter(Weld.Part1.Parent) then
-- code here. Check if it's a specific player, or whatever you wish to do
end
end
Written on the forum. If there are any issues please tell me.
You could also check to see if the Character’s humanoid Sit value is equal to true, so maybe something like this?
Adding onto your code:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
Humanoid.Changed:connect(function(Property)
if Property == "Jump" or Humanoid.Sit == true then
Humanoid.Jump = false
end
end)
You could create a table that will list all the possible seats maybe?
local Table = {
workspace.Seat1;
workspace.Seat2;
workspace.Seat3;
workspace.SpecialSeat;
}
Then go through the table inside that Changed function to check if the names of them are valid to players or special VIP players, otherwise it’ll turn back the Humanoid’s JumpPower to 50
for i,v in ipairs(Table) do
if v.Name ~= "SpecialSeat" then --You could put some other parameters here in the if statement
--Insert random stuff here
else
Humanoid.JumpPower = 50
Humanoid.Jump = true
end
end
Just a bland example though, I haven’t experimented with tables all that often