Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I tried to make an array of spawns, but it doesn't work?

I tried to make a script to when a player joins the game, it makes an array of all the different spawns, then teleports the player to one of the spawns randomly. But whenever someone joins the game, nothing happens. Sorry if this is crude, I'm somewhat new.

local s1 = script.Parent.Tpart1.Position
local s2 = script.Parent.Tpart2.Position
local s3 = script.Parent.Tpart3.Position
local s4 = script.Parent.Tpart4.Position
local plrs = game:GetService("Players")

local spawnarray = {s1, s2, s3, s4}

plrs.PlayerAdded:Connect(function(plr)
	plr.CharatcerAdded:Connect(function(char)
		wait(1)
		char.HumanoidRootPart.Position = (spawnarray[math.random(4)])
	end)
end)

1 answer

✓ Accepted answer

I believe you have misspelt CharacterAdded (you have spelt it CharatcerAdded) here I have fixed the problem:

local s1 = script.Parent.Tpart1.Position
local s2 = script.Parent.Tpart2.Position
local s3 = script.Parent.Tpart3.Position
local s4 = script.Parent.Tpart4.Position
local plrs = game:GetService("Players")

local spawnarray = {s1, s2, s3, s4}

plrs.PlayerAdded:Connect(function(plr)
    plr.Character:Connect(function(char)
        wait(1)
        char.HumanoidRootPart.Position = (spawnarray[math.random(4)])
    end)
end)

1 comment

0

Thank you, as I am blind.

This discussion is preserved as it was. New answers, comments, and votes are closed.