I am not sure why this happens. Here are the errors I get.
Attempt to index local player is what I see in the dev console
Tool = script.Parent
plr = game.Players.LocalPlayer.Character
function functionname()
local name = plr.Name
local playerinplayers= game.Players:FindFirstChild(plr.Name)
if playerinplayers ~= nil then
playerinplayers.CanLoadCharacterAppearance = false
plr.Head.face.Texture = "rbxassetid://28257733"
local bodycolors = Instance.new("BodyColors",plr)
bodycolors.RightArmColor = BrickColor.new("Pastel brown")
bodycolors.RightArmColor = BrickColor.new("Pastel brown")
bodycolors.LeftArmColor = BrickColor.new("Pastel brown")
bodycolors.RightLegColor = BrickColor.new("Pastel brown")
bodycolors.LeftLegColor = BrickColor.new("Pastel brown")
bodycolors.TorsoColor = BrickColor.new("Pastel brown")
bodycolors.HeadColor = BrickColor.new("Pastel brown")
game.ReplicatedStorage["Roblox 2.0 Left Arm"]:Clone().Parent = plr
wait()
game.ReplicatedStorage["Roblox 2.0 Left Leg"]:Clone().Parent = plr
wait()
game.ReplicatedStorage["Roblox 2.0 Right Arm"]:Clone().Parent = plr
wait()
game.ReplicatedStorage["Roblox 2.0 Right Leg"]:Clone().Parent = plr
wait()
game.ReplicatedStorage["Roblox 2.0 torso"]:Clone().Parent = plr
wait()
plr.Shirt:Destroy()
wait()
plr.Pants:Destroy()
local shirt = Instance.new('Shirt', plr)
shirt.ShirtTemplate = 'rbxassetid://153667173'
local pants = Instance.new('Pants', plr)
pants.PantsTemplate = 'rbxassetid://115544973'
for _,v in pairs(plr:GetChildren()) do
if v.ClassName == "Hat" then
v:Destroy()
wait()
game.ReplicatedStorage.GrayHair:clone().Parent = plr
wait()
game.ReplicatedStorage.GrayHair2:clone().Parent = plr
end
end
end
end
Tool.MouseButton1Click:connect(functionname)
