So I've got a script that's meant to randomly add an accessory to a player when they join from a folder in replicated storage but the script won't work, no errors come out but nothing happens at all.
local Teams = game:GetService("Teams")
local Hunters = Teams:FindFirstChild("Hunters")
local Folder = game.ReplicatedStorage:WaitForChild("HikingPacks")
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(player)
if player.Team == game.Teams["Hunters"] then
print("OnTeamHunters")
local Playername = player.Name
local PlayerCharacter = game.Workspace:WaitForChild(Playername)
local Humanoid = PlayerCharacter:WaitForChild("Humanoid")
print(Playername)
for i, Packs in pairs(Folder:GetChildren()) do
local Chosen = math.random(1, 3)
if Chosen then
Humanoid:AddAccessory(Chosen)
end
end
end
end)
Could someone tell my why? Thanks!

1 comment
Ok so I've done that, but realised that it wasn't printing the players name (mine in this case) so that's probably also a problem, why would it not be getting the username?