How do I detect/load in the player?

  1. What do you want to achieve? Keep it simple and clear!
    I want to load in a character into my game but I do not know how.

  2. What is the issue? Include screenshots / videos if possible!
    When I test my game in studio it does not automatically load in.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried making a simple script to load them in but I don’t think it works.

game.Players.PlayerAdded:connect(function(plr)
	print(plr.Name.." joined the game!")
end)

https://gyazo.com/57fdc97f4576df71672e7aa8183ad63d

Uhhh, what version of Studio is this? This version of Studio doesn’t have the play solo feature.

Use

plr.CharacterAdded:Connect(function(char)
end)

I think I may get what you mean,

game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:Connect(function(Character)
    if characterthen   
	print(plr.Name.." joined the game!")
end
end)
end)

1 Like

I think for this version, you do game.Players:CreateLocalPlayer(0) and then game.Players.LocalPlayer:LoadCharacter()

itz roblox studio, how do you test then, i am new to this! soz

If this is Clonetrooper’s Studio think from 2007, you need to actually make the local player. Let me quickly get the script so you can loadfile it

loadfile("rbxasset://../../extra/scripts/PlaySolo.lua")()

-- Services
local Visit = game:service("Visit")
local Players = game:service("Players")
local RunService = game:service("RunService")

-- Create Player
local player = game.Players.LocalPlayer

if not player then
	player = game.Players:createLocalPlayer(0)
end

local function waitForChild(parent,childName)
	local child
	
	while true do
		child = parent:findFirstChild(childName)
		
		if child then
			break
		else
			parent.ChildAdded:wait()
		end
	end
	
	return child
end

local function onChanged(property)
	if property == "Character" then
		local humanoid = waitForChild(player.Character, "Humanoid")
		
		humanoid.Died:connect(function ()
			wait(5)
			player:LoadCharacter()
		end)
	end
end

player.Changed:connect(onChanged)
player:LoadCharacter()

-- Start the game.
RunService:run()
5 Likes