Attempt to index nil with 'Character'

This script is supposed to change your clothes but for some reason, it will not work

local Player = game:GetService("Players").LocalPlayer

--Settings--

local Uniform = {}

Uniform.Shirt = "http://roblox.com/asset/?id=6269703399"

Uniform.Pants = "http://roblox.com/asset/?id=6269704507"

--function--

function AddUniform(P)

local Character = P.Character or P.CharacterAdded:Wait()

repeat wait(0) until Character ~= nil

for i,Object in next,Character:GetChildren() do

if Object:IsA("Shirt") or Object:IsA("Pants") then

Object:Destroy()

end

end

local Shirt = Instance.new("Shirt",Character) Shirt.ShirtTemplate = Uniform.Shirt local Pants = Instance.new("Pants",Character) Pants.PantsTemplate = Uniform.Pants

end

--GUIPart--

local Bin = script.Parent

if Bin:IsA("TextButton") or Bin:IsA("ImageButton") then

Bin.MouseButton1Down:connect(function()

AddUniform(Player)

end)

end

Is this in a LocalScript?

You only have access to the LocalPlayer through LocalScripts.