What am I doing wrong (shirt giver)

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)

You can try this:

local script

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)
2 Likes

Thank you so much, it worked!

dfs

You’ve got some errors in the script, which would be:

  1. In the if and elseif statements all of the links are the same, which was probably not the something you were going for

  2. 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:

  1. http://www.roblox.com/asset/?id=607785311
  2. http://www.roblox.com/asset/?id=7136156278
  3. http://www.roblox.com/asset/?id=6808801201
1 Like

About if statements, yeah that is my bad i copy pasted wrong script here

I will remember those things for the future, thank you

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.