Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Trying to get a TShirt to apply to a user when they click a GUI Button?

Asked by 3 years ago

I have a script that applies a specific Uniform to the player when they click it on the GUI. I tried adapting it to work with Tshirts but it seems to not work. I tried using this

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "Badge2"
local ShirtGraphic = "rbxassetid://5128483529"

function GiveUni(plr)
    local character = plr.Character
    local shirtgraphic = character.ShirtGraphic
    local pants = character.Pants
    shirtgraphic.Graphic = ShirtGraphic
end


Event.OnServerEvent:Connect(GiveUni)

But only to get the following error.

 01:08:05.942 - ShirtGraphic is not a valid member of Model
01:08:05.944 - Stack Begin
01:08:05.944 - Script 'ServerScriptService.Badge2', Line 8 - function GiveUni
01:08:05.945 - Stack End

So I'm confused as to where to go from here any help will be appreciated.

1 answer

Log in to vote
0
Answered by 3 years ago

You used the same variable twice:

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "Badge2"
local Shirtgraphic = "rbxassetid://5128483529" --  Same variable as line 7 used to be here.

function GiveUni(plr)
    local character = plr.Character
    local shirtgraphic = character.ShirtGraphic
    local pants = character.Pants
    shirtgraphic.Graphic = ShirtGraphic
end


Event.OnServerEvent:Connect(GiveUni)

Should Work. Or else try this:

local Event = Instance.new("RemoteEvent")
Event.Parent = game.ReplicatedStorage
Event.Name = "Badge2"
local Shirtgraphic = "rbxassetid://5128483529"

function GiveUni(plr)
    local character = plr.Character
    local shirtgraphic = character.ShirtTemplate 
    local pants = character.PantsTemplate
    shirtgraphic.Graphic = ShirtGraphic
end


Event.OnServerEvent:Connect(GiveUni)
0
First Option gives me the following error - 16:27:03.691 - ShirtGraphic is not a valid member of Model 16:27:03.693 - Stack Begin 16:27:03.693 - Script 'ServerScriptService.BadgeGive2', Line 8 - function GiveUni 16:27:03.694 - Stack End            ZeusLykaios 0 — 3y
0
Second one gives me this error - 16:55:29.376 - ShirtTemplate is not a valid member of Model 16:55:29.377 - Stack Begin 16:55:29.378 - Script 'ServerScriptService.BadgeGive2', Line 8 - function GiveUni 16:55:29.378 - Stack End ZeusLykaios 0 — 3y
Ad

Answer this question