Script not working

Script

local clone = AnimalModels[evolutionName.Value]:Clone()
	clone.Parent = workspace
	clone.Name = plrChar.Name

The error : attempt to index nil with ‘Name’

1 Like

You never defined the plrChar atlest not in the the script above.

2 Likes

Did “plrChar” is Character? or maybe can you show us your variable?

Sure 1 second I will do that right now.

local plrChar = plr.Character
local leaderstats = plr:WaitForChild(“leaderstats”)
local evolutionName = leaderstats:WaitForChild(“EvolutionName”)
wait(6)

local clone = AnimalModels[evolutionName.Value]:Clone()
clone.Parent = workspace
clone.Name = plrChar.Name
local plrChar = plr.Character
local leaderstats = plr:WaitForChild(“leaderstats”)
local evolutionName = leaderstats:WaitForChild(“EvolutionName”)
wait(6)

local clone = AnimalModels[evolutionName.Value]:Clone()
clone.Parent = workspace
clone.Name = plr.Name

Just do plr.Name because character is the model of your char, so it won’t work.

1 Like

Thank you a lot for your help!

1 Like

If this is a player starter script or on a PlayerAdded event then you cannot get the player character until it is loaded. If in player starter scripts, try putting it in character starter scripts. If on PlayerAdded try this

Players.PlayerAdded:Connect(function(plr)
    player.CharacterAdded:Connect(character)
        myfunction(plr)
    end)
end)