Button wont work

hi,
i made a gui where if you select a team kit and if u press the button to apply the kit on a certain team, it will change clothes of all the players of a team.
but i dont know why, when i click the button to change the players clothes, it wont work.
here the serverscript inside the button:

local text = script.Parent.Parent.NameKitGKAwaySelected
local function one()
	local PlayerTeam = game:GetService("Teams").GKAway:GetPlayers()
	for i,v in pairs(PlayerTeam) do
local found = v.Character:FindFirstChild("Shirt")
	if found and text.Text == "Raimon GK Kit" then 
			v.Character.Shirt.ShirtTemplate = "rbxassetid://10408338003"
			print("player wore the shirt")
			elseif found and text.Text == "Royal GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408327819"
			print("player wore the shirt")
			elseif found and text.Text == "Alpine GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408370090"
			print("player wore the shirt")
			elseif found and text.Text == "Occult GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408318163"
			print("player wore the shirt")
			elseif found and text.Text == "Farm GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408359263"
			print("player wore the shirt")
			elseif found and text.Text == "Zeus GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408379715"
			print("player wore the shirt")
			elseif found and text.Text == "Polestar GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408347032"
			print("player wore the shirt")
				elseif found and text.Text == "Shuriken GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408387289"
					
					print("Shirt Found")
			else
				
	print("Shirt Not Found")
	 local creator = Instance.new("Shirt", v.Character)
				creator.Name = "Shirt"
			if creator and text.Text == "Raimon GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408338003"

			elseif creator and text.Text == "Royal GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408327819"

			elseif creator and text.Text == "Alpine GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408370090"

			elseif creator and text.Text == "Occult GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408318163"

			elseif creator and text.Text == "Farm GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408359263"

			elseif creator and text.Text == "Zeus GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408379715"

			elseif creator and text.Text == "Polestar GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408347032"

			elseif creator and text.Text == "Shuriken GK Kit" then
				v.Character.Shirt.ShirtTemplate = "rbxassetid://10408387289"
		end
end
local found2 = v.Character:FindFirstChild("Pants")
				if found2 and text.Text == "Raimon GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408341755"

			elseif found2 and text.Text == "Royal GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408333115"

					elseif found2 and text.Text == "Alpine GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408374747"

					elseif found2 and text.Text == "Occult GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408323082"

					elseif found2 and text.Text == "Farm GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408285776"

					elseif found2 and text.Text == "Zeus GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408383404"

					elseif found2 and text.Text == "Polestar GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408353035"

						elseif found2 and text.Text == "Shuriken GK Kit" then
						v.Character.Shirt.ShirtTemplate = "rbxassetid://10408392701"
						print("Pants Found")
else
	print("Pants Not Found")
	local creator2 = Instance.new("Pants", v.Character)
							creator2.Name = "Pants"
				if creator2 and text.Text == "Raimon GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408341755"

				elseif creator2 and text.Text == "Royal GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408333115"

				elseif creator2 and text.Text == "Alpine GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408374747"

				elseif creator2 and text.Text == "Occult GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408323082"

				elseif creator2 and text.Text == "Farm GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408285776"

				elseif creator2 and text.Text == "Zeus GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408383404"

				elseif creator2 and text.Text == "Polestar GK Kit" then
					v.Character.Shirt.ShirtTemplate = "rbxassetid://10408353035"

					elseif creator2 and text.Text == "Shuriken GK Kit" then
						v.Character.Shirt.ShirtTemplate = "rbxassetid://10408392701"
						end
					end
	end
end

script.Parent.Activated:Connect(one)

if anyone can help me with this i would be really grateful

quick guess …

local Button = script.Parent
Button.MouseButton1Click:Connect(function(one)

i tried that one already, it still doesnt work :frowning:

Is there some rule that says you can’t upload right here your gui involved and other infromation needed? It’s a pain recreating all this just to find a missing comma or a script in the wrong place.

Should work in a localscript. Copy code to a localscript and run that.

but everyone should see it, not only you

in the first place i got like: Attempt to connect: Passed Value is not a valid function, but then i fixed it.
now it doesnt give me any error in the output

Try making it a local script and putting this at the bottom:

local Button = script.Parent
Button.MouseButton1Click:Connect(function()
	one()
end)

Brock this all the way down to would work if it was not a local script.

gkaway is not a valid member of teams “Teams” its bc u forgot to add the team

lol, ya I’ve never done that here yet. Just tring to get something working 1st then I’ll move on. Going off local script in gui with button as parent (for now).

you can’t use button.clicked or activated in the server, this will never work, instead use RemoteEvent to make this work on both side client/server.

ah lol, anyways let me try the suggestion of the local script

so i’ll just copy the function, paste when i do remote.OnserverEvent and then fire it in a local script?

Okay I did a server script and changed the Activate to this:

script.Parent.MouseButton1Click:Connect(one)

eh i did try it but it doesnt work…

use only the clint side when the player click on the button, when he does fire a remote event and add the function in the server with few changes like don’t check the text in the server

, basically all the stuff related to the button write it in the client side.

alright ill try it out tomorrow

Got it to the point it would work if not a local script … (and also learned how to create teams, lol)
Took a bit to covert it to a local script but, I don’t think there is anything wrong with it other than being in the wrong type of script, so … How to fire a remote event when a part is touched
Just look at how the fire event part is working. Set the click up to fire an event in the nonlocal script in ServerScriptService.

I rewrote your code and made it a lot simpler, but I’m not 100% this will work since your original code didn’t work either. Replace your script with this and see if it works.

local Teams = game:GetService("Teams")

local Team = Teams.GKAway

local Tool = script.Parent
local Label = Tool.Parent.NameKitGKAwaySelected

local Clothes = {
	["Raimon GK Kit"] = {"rbxassetid://10408338003", "rbxassetid://10408341755"},
	["Royal GK Kit"] = {"rbxassetid://10408327819", "rbxassetid://10408333115"},
	["Alpine GK Kit"] = {"rbxassetid://10408370090", "rbxassetid://10408374747"},
	["Occult GK Kit"] = {"rbxassetid://10408318163", "rbxassetid://10408323082"},
	["Farm GK Kit"] = {"rbxassetid://10408359263", "rbxassetid://10408285776"},
	["Zeus GK Kit"] = {"rbxassetid://10408379715", "rbxassetid://10408383404"},
	["Polestar GK Kit"] = {"rbxassetid://10408347032", "rbxassetid://10408353035"},
	["Shuriken GK Kit"] = {"rbxassetid://10408347032", "rbxassetid://10408392701"}
}

local function Activated()
	local PlayerTeam = Team:GetPlayers()

	for _, Player in PlayerTeam do
		local Character = Player.Character or Player.CharacterAdded:Wait()
		
		local Shirt = Character:FindFirstChildOfClass("Shirt")
		local Pants = Character:FindFirstChildOfClass("Pants")
		
		if not Shirt then
			Shirt = Instance.new("Shirt")
			Shirt.Parent = Character
			
			print("Created new shirt")
		end
		
		if not Pants then
			Pants = Instance.new("Pants")
			Pants.Parent = Character
			
			print("Created new pants")
		end
		
		for text, assets in next, Clothes do
			if Label.Text == text then
				Shirt.ShirtTemplate = assets[1]
				Pants.PantsTemplate = assets[2]
				
				print("Player wore the clothes")
			end
		end
	end
end

Tool.Activated:Connect(Activated)

I assumed it was a tool because of the usage of the Activated event, but if not, use this instead:

local Teams = game:GetService("Teams")

local Team = Teams.GKAway

local Button = script.Parent
local Label = Button.Parent.NameKitGKAwaySelected

local Clothes = {
	["Raimon GK Kit"] = {"rbxassetid://10408338003", "rbxassetid://10408341755"},
	["Royal GK Kit"] = {"rbxassetid://10408327819", "rbxassetid://10408333115"},
	["Alpine GK Kit"] = {"rbxassetid://10408370090", "rbxassetid://10408374747"},
	["Occult GK Kit"] = {"rbxassetid://10408318163", "rbxassetid://10408323082"},
	["Farm GK Kit"] = {"rbxassetid://10408359263", "rbxassetid://10408285776"},
	["Zeus GK Kit"] = {"rbxassetid://10408379715", "rbxassetid://10408383404"},
	["Polestar GK Kit"] = {"rbxassetid://10408347032", "rbxassetid://10408353035"},
	["Shuriken GK Kit"] = {"rbxassetid://10408347032", "rbxassetid://10408392701"}
}

local function Click()
	local PlayerTeam = Team:GetPlayers()

	for _, Player in PlayerTeam do
		local Character = Player.Character or Player.CharacterAdded:Wait()
		
		local Shirt = Character:FindFirstChildOfClass("Shirt")
		local Pants = Character:FindFirstChildOfClass("Pants")
		
		if not Shirt then
			Shirt = Instance.new("Shirt")
			Shirt.Parent = Character
			
			print("Created new shirt")
		end
		
		if not Pants then
			Pants = Instance.new("Pants")
			Pants.Parent = Character
			
			print("Created new pants")
		end
		
		for text, asset in next, Clothes do
			if Label.Text == text then
				Shirt.ShirtTemplate = asset[1]
				Pants.PantsTemplate = asset[2]
				
				print("Player wore the clothes")
			end
		end
	end
end

Button.MouseButton1Click:Connect(Click)