When player click button GUI, they get the shirt, but instead shirt doesn’t even load, am I doing something wrong?
local script
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.GiveShirt
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer("(shirt template)")
end)
server script
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.GiveShirt
RemoteEvent.OnServerEvent:Connect(function(player, shirtTemplate)
local Character = player.Character
if shirtTemplate == "607785314" then
Character.Shirt:Destroy()
local shirt = Instance.new("Shirt")
shirt.Parent = Character
Character:FindFirstChildOfClass("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=607785314"
elseif shirtTemplate == "7136156284" then
Character.Shirt:Destroy()
local shirt = Instance.new("Shirt")
shirt.Parent = Character
Character:FindFirstChildOfClass("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=607785314"
elseif shirtTemplate == "6808801205" then
Character.Shirt:Destroy()
local shirt = Instance.new("Shirt")
shirt.Parent = Character
Character:FindFirstChildOfClass("Shirt").ShirtTemplate = "http://www.roblox.com/asset/?id=607785314"
end
end)
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.GiveShirt
script.Parent.MouseButton1Click:Connect(function()
RemoteEvent:FireServer(7136156284) -- shirt id
end)
server script
local ReplicatedStorage = game.ReplicatedStorage
local RemoteEvent = ReplicatedStorage.GiveShirt
RemoteEvent.OnServerEvent:Connect(function(player, shirtTemplate)
local Character = player.Character
Character.Shirt.ShirtTemplate = game:GetService("InsertService"):LoadAsset(shirtTemplate).Shirt.ShirtTemplate
end)
You’ve got some errors in the script, which would be:
In the if and elseif statements all of the links are the same, which was probably not the something you were going for
Some player’s characters don’t even have a shirt on, so be sure to include an if statement to confirm that they have the shirt, else, just create a new one.
And the reason for it to not work, is that the ids used don’t work when just copy and pasted. It normally works in the studio (when the game isn’t running), as it automatically changes it to the correct id.
So the supposedly correct id you should use would be: