Automatically Spawning Players

I want to automatically make a player load into the game upon joining. But would the script go inside of a Local or Server script? It currently is inside of a server script and it respawns both players.

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
    Player:LoadCharacter()
end)

hi!

:LoadCharacter is reserved for server-side scripts.

what do you mean by “it respawns both players.”, is it not supposed to respawn?

1 Like

Hello and nevermind I managed to fix the issue but I also have an question I want to make it so if a value is true right and someone resets, upon the humanoid dying they would be reset but it is not working. Because I have a system in place where if the character resets or dies an GUI is enabled for them but I want to make it so if they are in the lobby (there is a boolean value that tells when they are in lobby) then if they reset then they would just be reset instead of the GUI appearing. How would I go about doing this because it can’t be performed within a LocalScript?

hey!

if you want the player to respawn on death only if a certian value is on, do this:

-- settings
local respawntime = 3

-- services
local players = game:GetService("Players")

-- characteradded
local function characteradded(player, character)
	-- died
	character:WaitForChild("Humanoid").Died:Connect(function()
		if workspace.Value.Value then -- idk where ur value is
			task.spawn(function()
				task.wait(respawntime)
				player:LoadCharacter()
			end)
		end
	end)
end

-- playeradded
local function playeradded(player)
	player.CharacterAdded:Connect(function(character)
		characteradded(player, character)
	end)
	player:LoadCharacter()
end

-- connection
players.PlayerAdded:Connect(playeradded)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.