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

Character Not Spawning to Spawn Point When Join?

Asked by 6 years ago
Edited 6 years ago

When the player joins the game, the character is supposed to spawn to a specific spawn according to their player number and the spawn name. For some reason it doesn't work. Can someone help? (Script is inside a normal script in ServerScriptStorage)

01game.Players.PlayerAdded:Connect(function(player)
02    local playernum = Instance.new("StringValue")
03    playernum.Parent = player
04    playernum.Name = "Player"
05    local players = game.Players:GetPlayers() --Gets how many players there are when a player joins the game
06    for _, v in pairs(players) do
07        playernum.Value = "Player"..#players --The value is how ever many players there are
08    end
09    player.CharacterAdded:Connect(function(char)
10        local humanoid = char:WaitForChild("Humanoid")
11        local spawnlocations = game.Workspace:WaitForChild("BloxopolyBoard"):WaitForChild("SpawnLocations"):GetChildren() --Gets all the children in the spawn locations
12local spawnfolder = workspace:WaitForChild("BloxopolyBoard"):WaitForChild("SpawnLocations")
13        if humanoid then --If the humanoid exists
14            for i, v in pairs(spawnlocations) do
15                if playernum.Value == v.Name then --If the player's number matches the name of one of the spawn locations
View all 23 lines...

It just stops working up until the print(), but I get no errors.

0
IS the spawn name just a number? Nooberton_1 9 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

It month be that playernum Is a StringValue instead of aIntValue

Ad

Answer this question