14:12:37.638 - ServerScriptService.Main_Script:92: attempt to index local 'player' (a nil value)
how would i make this work? The reason i ask is because i'm trying to organize the clothes within a folder thats in Assets. Then have it find the required clothes according to the team the player is on. CODE BELOW
local Storage = game:getService("ReplicatedStorage") function Change_Clothes(char) for _,x in next,char:GetChildren()do if x:IsA("Hat")or x:IsA("Shirt")or x:IsA("Pants")then x:Destroy() end end local player = game.Players:GetPlayerFromCharacter(char.Parent) Storage.Assets[player.Team].Shirt:Clone().Parent = char Storage.Assets[player.Team].Pants:Clone().Parent = char Storage.Assets[player.Team].Hat:Clone().Parent = char end game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) wait(1) Change_Clothes(char) print(player.Name.." has joined!") end)
The reason it's erroring is because you're calling the method on Workspace! If you go back to line 10, you put char.Parent
, but you need to put char
. GetPlayerFromCharacter requires the chawracter, which you already defined with char
.