Hi, I have script which giving T-shirt (decal), but something is wrong here in 4 line. Exactly Players.DodusiakPL.PlayerGui.UniformGui.Frame.US.Ubranie.Script:4: attempt to index nil with 'Character'. I don't have idea what's wrong, any ideas?

This is this script


local Decal = script.Parent:FindFirstChildOfClass("Decal")

script.Parent.MouseButton1Click:connect(function(Player)
    local Character = Player.Character
    for i,v in pairs(Character:GetDescendants()) do
        if v:IsA("ShirtGraphic") then
            v:Destroy()
        end
    end
    local ShirtGraphic = Instance.new("ShirtGraphic")
    ShirtGraphic.Graphic = Decal.Texture
    ShirtGraphic.Parent = Character
end)

5 comments

0

Few questions, is the script written in a LocalScript or a Script, and is the script's Parent a button?

0

normal script and yes

0

The thing is MouseButton1Click doesn't have a parameter Player, so your variable Player will always be nil no matter what. I recommend switching to LocalScript

0

and use RemoteEvent and Regular Scripts to change the Player's TShirt

0

So how gonna now looks this script