What is wrong with my Script; Trying to clone a Hat onto a Person

  1. What do you want to achieve?
    I want this Script to clone a Hat into the Players Avatar (Server Sided also)

  2. What is the issue?
    Not entirely sure, I guess my script isn’t right. It just isn’t cloning.
    I do have this is the Output, bu it doesn’t tell me anything:
    12:14:09.211 Stack Begin - Studio
    12:14:09.211 Script ‘Workspace.Script’, Line 4 - Studio - Script:4
    12:14:09.212 Stack End - Studio

  3. What solutions have you tried so far?
    I currently don’t know what to do, so I am coming to the Developer Forum.

  4. Code In Script

local player = game:GetService("Players")
local playerName = player.Name
local mask1 = game.ReplicatedFirst:WaitForChild("DoctorsMask")
local playerAv = game.Workspace:WaitForChild(playerName)

mask1:Clone().Parent = playerAv

Thanks, AridOats!

If i think what you’re doing is putting a mask on every player that joins, you can go on Game Settings > Avatar and force all players to have that item.

If not, a way to make that script better is to just get the player, then use Player.Character.

Don’t do game.Workspace.PlayerName.

Do player.Character

Display Names are coming and that work would not work;

This is how you should do:

local mask1 = game.ReplicatedFirst:WaitForChild("Doctors mask")
        mask1:Clone().Parent = chr

This would be inside ServerScriptService as a normal script;