Make player spawn in seat?

Parenting a spawnlocation with the size of 1,1,1 to a seat? and using MoveTo() to make the player move. Because if the player doesnt move then, he can’t take the seat

2 Likes

well when you spawn you will sit down, but this will not keep you in place, so if what @cx15y is making moves then it might not work very well.

Okay, I’m back with working code.

Put this in ServerScriptService (any script. New or already existing, doesn’t matter.)

local Players = game:GetService("Players")

local seat = workspace:WaitForChild("Seat")

Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	if character and seat then
		task.wait(0.3)
		
		character.HumanoidRootPart.Position = seat.Position
	end
end)
3 Likes

The seat has a proximity prompt on it, so its just makes the player stand on top of it

1 Like

Keep the same code I already gave you, but at the end of seat.Position, add “+ Vector3.new(5, 0, 0)”

Like this:

local Players = game:GetService("Players")

local seat = workspace:WaitForChild("Seat")

Players.PlayerAdded:Connect(function(player)
	local character = player.Character or player.CharacterAdded:Wait()
	
	if character and seat then
		task.wait(0.3)
		
		character.HumanoidRootPart.Position = seat.Position + Vector3.new(5, 0, 0)
	end
end)

Check this post out, maybe do some research before posting about it

use playeradded to check if new player has joined / been added then
Seat:Sit(humanoid) - forcefully sits player
(havent tested)

It just does the same thing but in a slightly different place

The intent is to spawn them slightly farther away and the player uses the prompt to sit in the seat. To get them in the seat without using the prompt, that needs more code I can’t type right now. I just got hospitalized, so I can’t really write a script right now lol

local Game = game
local Workspace = workspace
local Seat = Workspace:FindFirstChild("Seat") or Workspace:WaitForChild("Seat")
local Players = Game:GetService("Players")
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChildOfClass("Humanoid") or Character:WaitForChild("Humanoid")

Seat:Sit(Humanoid)

The Sit method of ‘Seat’ instances is purposed for this.
https://developer.roblox.com/en-us/api-reference/function/Seat/Sit

1 Like

Oh man, I hope you get better.

2 Likes
local Players = game:GetService("Players")

local Chair = game.Workspace.Chair -- whatever your value is 

Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char.HumanoidRootPart.Position = Chair.Position
        Chair:Sit(plr.Humanoid)

Something like this should work.

Its says position is not a valid member of part “cx15y.HumanoidRootPart”

make sure you are using char which would be Player.Character. Try it with plr.Character.HumanoidRootPart.

It still says the same thing as before, Sorry for the 6 day wait.

Hmmmm… I recommend trying something like this:

local Players = game:GetService("Players")

local Chair = game.Workspace.Chair -- whatever your value is 

Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        char:MoveTo(Chair.Position)
        Chair:Sit(char.Humanoid)

I’m not sure why, but it still has the same error message, did you see i said the seat had a proximity prompt and is this script is supposed to go into serverscriptservice?

It’s not the character you’re using, it’s the player. Humanoids are not present in the player, so use the character instead

local Players = game:GetService("Players")

local Chair = game.Workspace.Chair 

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAdded:Connect(function(char)
		repeat
			wait(0.5)
		until char:FindFirstChild("Humanoid")
		Chair:Sit(char:WaitForChild("Humanoid"))
	end)
end)

2 Likes

Use char:WaitForChild(“Humanoid”) instead of that repeat loop

local Players = game:GetService("Players")

local Chair = game.Workspace.Chair 

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		local Humanoid = Character:WaitForChild("Humanoid")
		Chair:Sit(Humanoid)
	end)
end)

The script that I made is for player joining and forced to sit at different seats, but you could also use this to force someone into one seat instead of multiple seats.

local chairFolder = game.Workspace.Chair
local Players = game.Players

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

function seatPlayers(player)
	local character = player.Character or player.CharacterAdded:Wait()
	local hum = character:FindFirstChildOfClass("Humanoid")
	hum:SetStateEnabled(Enum.HumanoidStateType.Jumping, false)
	if hum then
		--Looks through all seats in the table and checks if they're taken.
		for i, v in pairs(seatStatus) do
			if v.taken == false then
				wait(0.5)
				v.chair:Sit(hum)
				v.taken = true
				break
			else --If it is taken, will continue untl 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
3 Likes