Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you keep players locked in their seats?

Is there any code anyone can send me to keep my players in their seat for a specific amount of time and then when I chose they can jump out their seat?

2 answers

We can use Humanoid:SetStateEnabled and Seat:GetPropertyChangedSignal to achieve this.

local seat = path.to.Seat -- please change path.to.seat to your seat, HAS TO BE A Seat Instance
seat:GetPropertyChangedSignal("Occupant"):Connect(function() -- get the event signal and connect it to the function
    local occupant = seat.Occupant -- get the humanoid of the occupant!!
    if occupant then -- if there is a occupant
        local p = game:GetService("Players"):GetPlayerFromCharacter(occupant.Parent) -- get the player from the parent of humanoid
        if p then -- if there is a player then
            occupant:SetStateEnabled(Enum.HumanoidStateType.Jump, false) -- disable jumping.
            wait(0) -- change 0 to your time you want to wait.
            occupant:SetStateEnabled(Enum.HumanoidStateType.Jump, true) -- enable jumping
        end
    end
end)

Please mark this as a solution if this works in your context, Metatable out!

4 comments

0

appreciate you answering me, but I'm a scripting beginner and I don't understand what you mean by 'please change path.to.seat to your seat, HAS TO BE A Seat Instance' , '- get the event signal and connect it to the function', '-- get the humanoid of the occupant!!, if there is an occupant.', and 'get the player from the parent of humanoid', and when to use false and true to enable and disable,

0

Please explain, thanks!

0

alright. path.to.seat should be changed to the seat you want to have the ability. on line 7, change wait(0) to wait(5). This will wait 5 seconds to reset the jumping ability.

0

@besltonefootballer just made an explanation!

Name= "Put in Username" game.Workspace:FindFirstChild(Name).Humanoid.UseJumpPower=false game.Workspace:FindFirstChild(Name).Humanoid.JumpHeight=0 wait(5) game.Workspace:FindFirstChild(Name).Humanoid.UseJumpPower=true game.Workspace:FindFirstChild(Name).Humanoid.JumpHeight= Your Original JumpHeight you have to change the script to make it do what you said.

what this script does: it disables the JumpPower (The Player has to be seated) and then after 5 Sek it Turns it on Again.

2 comments

0

to late? XD

0

That's not what they were asking for, exactly.

This discussion is preserved as it was. New answers, comments, and votes are closed.