So I want to make a game where when a player joins, their character gets added and it looks like them. Here is my script (I am using MessagingService because I want the character to be in every server:
--in a script in serverscriptservice
local mesaggingService = game:GetService("MessagingService")
game.Players.PlayerAdded:Connect(function(plr)
print("Player Joined")
local char = plr.Character or plr.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
mesaggingService:PublishAsync("New Player", {plr.Name, plr.UserId})
end)
mesaggingService:SubscribeAsync("New Player", function(info)
local clone = game:GetService("ServerStorage"):WaitForChild("NPC"):Clone()
local humanoid = clone:WaitForChild("Humanoid")
local info = info.Data
clone.Name = info[1]
print(info[1]) --prints my name
print(info[2]) --prints my userid
local playerDesc = game.Players:GetHumanoidDescriptionFromUserId(info[2])
print(playerDesc) -- this prints HumanoidDescription
humanoid:ApplyDescription(playerDesc)
clone.Parent = workspace
print("Created") -- this doesn't print
end)

1 comment
I just had to put the ApplyDescription line AFTER I set the parent.