Why does this not work? trying to change the players character to a model in rep storage and it doesnt give any errors
local rep = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local characterModels = {
Barbarian = rep.Classes:WaitForChild("Barbarian"),
Knight = rep.Classes:WaitForChild("Archer"),
Mage = rep.Classes:WaitForChild("Mage")
}
local function changeCharacter(player)
local playerClass = player:FindFirstChild("Class")
if playerClass and characterModels[playerClass.Value]then
if player.Character then
player.Character:Destroy()
end
local newCharacter = characterModels[playerClass.Value]:Clone()
newCharacter.Parent = workspace
player.Character = newCharacter
player:LoadCharacter()
print("")
end
end
players.PlayerAdded:Connect(function(player)
player:WaitForChild("Class").Changed:Connect(function()
changeCharacter(player)
end)
changeCharacter(player)
end)