Okay so I have been trying to fix my script that removes a players clothing, hats and sets the body color to a color that the player selected in a GUI. I am having a issue with the script and I don't understand why this error is happening.
I have the script placed in StarterCharacterScripts which is a child of StarterPlayer and the script is a LocalScript.
Here is the script.
script.Parent:WaitForChild("Humanoid").Died:connect(function()
wait(5)
local character = script.Parent
local children = character:GetChildren()
local skin = game.Players.LocalPlayer.Information.Skin.Value
if children:FindFirstChild("Shirt") then
local a = children:FindFirstChild("Shirt")
a:Destroy()
end
if children:FindFirstChild("Pants") then
local b = children:FindFirstChild("Pants")
b:Destroy()
end
if children.Head:FindFirstChild("face") then
local c = children.Head:FindFirstChild("face")
c:Destroy()
end
local d = children:FindFirstChild("Body Colors")
d:Destroy()
local e = game.ReplicatedStorage[skin]:FindFirstChild("Body Colors")
local f = e:Clone()
f.Parent = children
for i = 1, #children do
if (children[i].className == "Hat") then
children[i]:Remove()
end
end
end)
Sorry if this script is longer than it needs to be, it just helps me understand what is going on when I write it.
My previous script that I made and was using, it was working in studio but when a player died in game, it would set all player's body colors to the player that died. This was the next best thing I could think that would work but I guess I was wrong. All help will be greatly appreciated.
