Hey. So I am trying to make a dummy in my game become the player’s avatar. Though there is a problem. It changes the dummy to the NEWEST player added. For example, I join the game and it becomes my avatar, but then someone else joins and it becomes their avatar. I am trying to make it so it only becomes the local player’s avatar, without it changing to someone else’s. I will explain more if I am not clear enough on what I am trying to do.
If anyone trys to help me, I want them to modify this script:
local Players = game:GetService("Players");
local Dummy = workspace.Morphs.AvatarMorph
local DummyHumanoid = Dummy.Humanoid
Players.PlayerAdded:Connect(function(plr)
local humDes = Players:GetHumanoidDescriptionFromUserId(plr.UserId);
if(humDes)then
DummyHumanoid:ApplyDescription(humDes);
end
end)
local Players = game:GetService("Players");
local Dummy = workspace.Lobby.AvatarMorph
local DummyHumanoid = Dummy.Humanoid
Players.PlayerAdded:Connect(function(plr)
local humDes = Players:GetHumanoidDescriptionFromUserId(plr.UserId);
if(humDes)then
DummyHumanoid:ApplyDescription(humDes);
end
end)
You’re running this in the server and using PlayerAdded, which will fire every time any player is added. To make the NPC look like the local player, make a local script in StarterCharacterScripts. Try something like this:
local Players = game:GetService("Players")
local localPlayer = Players.LocalPlayer
local Dummy = workspace.Morphs.AvatarMorph
local DummyHumanoid = Dummy.Humanoid
local humDes = Players:GetHumanoidDescriptionFromUserId(localPlayer.UserId);
if(humDes)then
DummyHumanoid:ApplyDescription(humDes);
end
Sorry, I didn’t realize that doesn’t work on client. This script will create a new model that looks like the player, you just need to put a part named Placeholder at the dummy’s position and get rid of the dummy.
local Players= game:GetService("Players")
local placeholder = workspace.Morphs.AvatarMorphs.Placeholder
local function cloneCharacter(playerID, playerName)
local clonePlayer = Players:CreateHumanoidModelFromUserId(playerID)
clonePlayer.Name = playerName
clonePlayer.PrimaryPart.Position = placeholder.Position
clonePlayer.PrimaryPart.Anchored = true
clonePlayer.Name = "Dummy"
clonePlayer.Parent = workspace
end
local player = Players.LocalPlayer or Players:GetPropertyChangedSignal("LocalPlayer"):wait()
cloneCharacter(player.userId, player.Name)
It should be a local script in starter character.
Anything that you want to appear separately for every client should be in a LocalScript, and the only places where LocalScripts run are the Player’s Backpack, StarterCharacterScripts (or in the StarterCharacter), StarterPlayerScripts, PlayerGui, and ReplicatedFirst.