Make player spawn in seat?

I’m trying to make the player spawn in a seat when they join the game. But I can’t get anything to work.

5 Likes

You’re simply trying to get them to spawn on a seat upon the player joining? Or for both joining and when they die?


If you’re trying to do this only when they join, try 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 then
		character.PrimaryPart.CFrame = seat.CFrame
	end
end)

Of course you can change up the “seat” variable to wherever the seat part is located if it isn’t a child of simply the Workspace

2 Likes

well, you could make the spawn point the part you sit on, then add the back part of the seat. Then put in this code to the back part or the part you sit on.

Here is the script:

Oopsies. This wouldn’t work. Ignore this!!

I’ll be back soon with working code lol

part.Touched:Connect(funtion(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
Hit.Parent.Humanoid.Sit = true 
            end
      end
end)```

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.