Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 5 years ago
Edited 5 years ago

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

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

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)

0
Thank you, as I am blind. ProjectJager 62 — 5y
Ad

Answer this question