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.
What is the issue? Include screenshots / videos if possible!
When I test my game in studio it does not automatically load in.
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)
game.Players.PlayerAdded:connect(function(plr)
plr.CharacterAdded:Connect(function(Character)
if characterthen
print(plr.Name.." joined the game!")
end
end)
end)
-- 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()