How do I make it so players spawn in chairs

Hello, recently I’ve made a game and I want to make a really weird game where you hang in a chair. I already made the animations, chair and all of the other stuff. But I can’t figure out how to make it so when you join the game, you spawn in the chair and can’t get out. Here’s a quick video of what I have so far.

The video

if you could help me out I’d appreciate it.

9 Likes

You can use Seat:Sit() to force a player into a seat, and the game.Players.PlayerAdded event to detect when a player joins.

Example:

game.Players.PlayerAdded:Connect(function(player)
    character = player.Character or player.CharacterAdded:Wait()
    Humanoid = character:WaitForChild("Humanoid")
    Seat:Sit(Humanoid)
end)

Amazing concept by the way. I got a good laugh out of that video.

15 Likes

Hm, this is an interesting idea for a game, well, you could when players spawn, (By the way this is hypothetical, I don’t know if this is true) turn on their sit boolean value in their humanoid and lock them to the chair, the reason for this are seats can be weird, especially in this case. Other than that you just have to have them spawn on the chair seat wait for the character to sit, then dangle the chair over the edge.

I suggest you weld the seat into the player and use Humanoid:Seat().

I can’t stop laughing whle watching the video

1 Like

I’ll try this out and I’m glad you find the video funny.

1 Like

Use a CharacterAdded Event to detect when a player’s character is added, use the function

the_name_of_the_seat:Sit(The character’s Humanoid) (Example: Seat:Sit(Character.Humanoid)

1 Like

This Your old post was wrong.

Sit is not a function of humanoid, it is a boolean that describes whether or not the player is sitting.

You may be thinking of SeatPart:Sit which takes a Humanoid as it’s only argument.

@DiamondGenius7513 I believe you are thinking of the Humanoid:Sit() function.

The way I personally would do this is using the aforementioned SeatPart:Sit method followed by setting the humanoid’s JumpPower to 0 (prevent them from escaping the seat).

Here’s an example code:

local Players = game:GetService("Players")
local seat = -- Define your Seat Instance.

Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	seat:Sit(character.Humanoid)
	character.Humanoid.JumpPower = 0
end)
2 Likes

There is no function of the Humanoid called :Seat() as of now. You can use Seat:Sit() to force a player into a seat, though.

1 Like

Sorry about the typo in my original post. I agree that this would be the best way to do it.

2 Likes

would I put the script in Workspace?

Yes, putting it in workspace would work.

I put the script in Workspace and it didn’t work.

Does it for single seat or multiple seat?

Ah sorry about that, it looks like it was checking for the player’s character before it loaded in, thus it returned nil when trying to reference it. I switched it to .CharacterAdded instead of .PlayerAdded - let me know if the issue persists.

-- Services
local Players = game:GetService("Players")

-- Variables
local chairFolder = game.Workspace.ChairFolder

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
    {chair = chairFolder.Chair1, taken = false},
    {chair = chairFolder.Chair2, taken = false},
    {chair = chairFolder.Chair3, taken = false},
    {chair = chairFolder.Chair4, taken = false}
}

function seatPlayers(character)
    local hum = character.Humanoid
    hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- To make the player unable to jump
    if hum then
        -- Looks through all seats in table and checks if they're taken
        for i, v in pairs(seatStatus) do
            if v.taken == false then  -- If it's not taken, it will sit player in it, and stop looping through the table
                v.chair:Sit(hum)
                v.taken = true
                break
            else -- If it is taken, it will continue until the end of the table, or until it finds a chair not taken
            end
        end
    end
end

Players.CharacterAdded:Connect(seatPlayers) -- Fires the seatPlayers function when a player joins the game
1 Like

nil

When I did that, it says “attempt to index nil with ‘Humanoid’” on line 15 in the script.

Add a spawn location somewhere, and add the following script.

local Spawn = game.Workspace.SpawnLocation
local Seat = game.Workspace.Seat


Spawn.Touched:Connect(function(hit)
	if hit.Parent:FindFirstChild("HumanoidRootPart") then
		local HumanoidRootPart = hit.Parent.HumanoidRootPart
		for i = 0,1,0.1 do
			wait()
			HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:Lerp(Seat.CFrame, i)
		end
	end	
end)
2 Likes

Check back on the post - I updated it.

Unfortunately I accidently edited the post instead of making a new reply :man_facepalming:t2:

it still says something is nil.

-- Services
local Players = game:GetService("Players")

-- Variables
local chairFolder = game.Workspace.ChairFolder

-- Table to hold the chair variables, and if they're taken or not
local seatStatus = {
    {chair = chairFolder.Chair1, taken = false},
    {chair = chairFolder.Chair2, taken = false},
    {chair = chairFolder.Chair3, taken = false},
    {chair = chairFolder.Chair4, taken = false}
}

function seatPlayers(player)
    local character = player.Character or player.CharacterAdded:Wait()
    local hum = character.Humanoid
    hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false) -- To make the player unable to jump
    if hum then
        -- Looks through all seats in table and checks if they're taken
        for i, v in pairs(seatStatus) do
            if v.taken == false then  -- If it's not taken, it will sit player in it, and stop looping through the table
                v.chair:Sit(hum)
                v.taken = true
                break
            else -- If it is taken, it will continue until the end of the table, or until it finds a chair not taken
            end
        end
    end
end

Players.PlayerAdded:Connect(seatPlayers) -- Fires the seatPlayers function when a player joins the game

nil

Maybe if I just had the seats in there instead?
here’s what it looks like in the folder.

setup