There are several issues with the script that cause the weird error:
-
local clientdirectory = Instance.new("Model") clientdirectory.Name = "Client_Directory" clientdirectory:Clone().Parent = workspace
Here you are creating a model, and once the model is created, it’s parent is set to NIL.
clientdirectory:Clone().Parent = workspace
This line is cloning the model to workspace
However, this is cloning it not declaring the initial value, meaning that now you have 2 model is the game:
- clientdirectory model which parent is NIL
- clientdirectory model which is put inside workspace
And even if your code is working, the
local clientdirectory = Instance.new("Model") ~= clientdirectory:Clone().Parent = workspace
-
local PlayerCheck = Players:GetPlayerFromCharacter(character)
local Model = game.Workspace:FindFirstChildWhichIsA("Model")
These lines are meaningless
At first here you are detecting when player is joined into the game, which is correct and which means we already have the player instance
game.Players.PlayerAdded:Connect(function(player) -- "player"
Also for the Character
player.CharacterAdded:Connect(function(character) -- character
since that’s a player and the function “CharacterAdded” returns “character” model
-
local ModelName = Model.Name
if ModelName == PlayerCheck.Name then
Model.Parent = game.Workspace.Client_Directory
end
Here these lines are checking the the character 's name is the player’s name which we don’t need.
Also if there another model in the workspace it would cause an issue.
Here is the fixed script:
local Players = game:GetService("Players")
local clientdirectory = Instance.new("Model")
clientdirectory.Name = "Client_Directory"
clientdirectory.Parent = game.Workspace
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
task.wait() -- a little wait before the character is completelly inside workspace
character.Parent = clientdirectory
end)
end)
If I have mistake, you don’t understand something or I have mistake, go ahead and feel free to reply! 