How would I spawn each player at their own spawn point with their own kart

For the cart spawning with their name use a billboard GUI, for them to spawn on their cart just teleport them right above their carts seat when the round starts, maybe use a GUI to mask the effect.

3 Likes

Thank you, but the main problem is about spawing the players karts at a location e.g. spawn1 - spawn5. Because if i use math.random, some of the karts could overlap in each other

Oh, well in that case I would use a for loop to put them in their spot, something that adds 1 every time it runs and then I would name the spots “Spot1”, “Spot2”, etc. I would then tp the player to the Spot using concatenation, “TeleportCart(“whatever player/cart your teleporting”, Spot…v). I hope this makes sense, if it does not feel free to ask questions.

3 Likes

That makes sense and I feel like I am on the right trail, Thank you so much for your time. I will check if this works in the morning as it is late where I am

Np, it’s like 2:30 am for me so I’m gonna go to bed, tomorrow I will help if it does not work.

There is a function you can use to force a player to sit in a seat.

https://developer.roblox.com/en-us/api-reference/function/Seat/Sit

If you want to have a random list you can get all the players. Then yo would need to jumble the list with an algorithm. Then loop through the jumbled list and sit each humanoid in their respective seats

3 Likes

Script it to choose a random number and put one cart there. Then script it to choose a random number excluding the previous number chosen and put a cart there, repeat that a few times.

yeh, thats the thing, i haven’t been able to get rid of the previous number, do you know how to do it?

No, if I knew scripting then I would have just wrote the script for you.

alright, thanks for the heads up anyways

3 Likes

I have tried to script it but has not succeeded. Is it possible for you to give a quick example or even write part of the script. You do not have to though, and no pressure.

2 Likes

ok, I will attempt to give an example.

local Carts = game.ReplicatedStorage.Carts:GetChildren() --I would put the carts in a folder in rep storage, you can change this though.

local function TeleportCarts(Cart, Spot)
	--blah blah blah this function teleports Cart to Spot, I do not know much about your game so I cannot write it for you
end

local function TeleportPlayer(Player, Cart)
	--this would teleport the Player to their Cart.
end
for i = 1, #Carts, 1 do
	local NumString = tostring(i)
	TeleportCarts(game.ReplicatedStorage.Carts:FindFirstChild("Cart"..NumString), CFrame.new(0, 0, 0)) --change Cframe to location you want the carts to go to
	
	TeleportPlayer(game.ReplicatedStorage.Carts:FindFirstChild("Cart"..NumString).Owner.Value, game.ReplicatedStorage.Carts:FindFirstChild("Cart"..NumString)) --I would add a value into each cart saying who owned it.
end

--I did not test this, hope it helps though!

I am still confused, do you mind if you tell me what value it is? I used a string value and it errored. It said

ServerScriptService.Script:25: attempt to index nil with 'Owner'

Is this because i used the wrong value for ‘Owner’

I would highly appreciate it if you could even go out of your way to make it in studio and send it as a file. Or even to make a model for it

Did you put the string value in the car?

I cannot as I do not know much about the cars you are using/how the rest of your game works, sorry.

I have done what you have said but have run into a problem, it is saying that ‘Player’ is nil which means that I can’t teleport the player. I have checked by printing the player.Name and it has come up with nil

local Carts = game.ReplicatedStorage.Carts:GetChildren()

local function TeleportCarts(Cart, Spot)
	print("Teleport Carts")
	Cart.Parent = workspace.Carts
end

local function TeleportPlayer(Player, Cart)
	print("teleport Player")
	print(Player.Name)
	Player.Character.HumanoidRootPart.Position = CFrame.new(9, 8, 17)
end


game.Players.PlayerAdded:Connect(function()
	wait(15)
for i = 1, #Carts, 1 do
		local NumString = tostring(i)
		print("Cart"..NumString)
	TeleportCarts(game.ReplicatedStorage.Carts:FindFirstChild("Cart"..NumString), CFrame.new(9, 5, 17)) 
	TeleportPlayer(game.Workspace.Carts:FindFirstChild("Cart"..NumString).Owner.Value, game.Workspace.Carts:FindFirstChild("Cart"..NumString))
	end
end)

The output says
ServerScriptService.Script:18: attempt to index nil with ‘HumanoidRootPart’
and the print where I did (Player.Name) comes up with nil in the output
Any ideas why?

You can make one IntValue for each player that values are the spawns.

Imagine my Value is 3 then I will spawn on the left and my friend value is 2 he will spawn in my right.

That is a great idea, but how would I give players a number with a script? And also so the players numbers would subtract by 1 if a player leaves so the numbers don’t eventually get a lot higher

make one math.Random imagine if 1 then my value is 1 but you have to make one check for see if others players dont get the same value too.