Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do you keep players locked in their seats? [closed]

Asked by 3 years ago

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?

Closed as Not Constructive by Nguyenlegiahung, FunctionalMetatable, Dovydas1118, and Leamir

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 3 years ago

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!

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, besltonefootballer -7 — 3y
0
Please explain, thanks! besltonefootballer -7 — 3y
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. FunctionalMetatable 490 — 3y
0
@besltonefootballer just made an explanation! FunctionalMetatable 490 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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.

0
to late? XD helloneighbor1016 16 — 3y
0
That's not what they were asking for, exactly. Qariter 110 — 3y