Gui leaderstat issue

for _, player in pairs(game:GetService('Players'):GetPlayers()) do
	if player:IsA('Player') then
		if player:FindFirstChild('leaderstats', false) then
			local leaderstats = player:FindFirstChild('leaderstats', false)
			if leaderstats:IsA('Folder') then
				if leaderstats:FindFirstChild('Kills', false) then
					local kills_val = leaderstats:FindFirstChild('Kills', false)
					if kills_val:IsA('ValueBase') then
						kills_val:GetPropertyChangedSignal('Value'):Connect(function()
							if player.Team == game:GetService('Teams'):FindFirstChild('Blue', false) then --// Enter your team name here
								script.Parent:FindFirstChild('BlueTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text = tostring(kills_val.Value)
							elseif player.Team == game:GetService('Teams'):FindFirstChild('Green', false) then --// Enter your team name here
								script.Parent:FindFirstChild('GreenTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text = tostring(kills_val.Value)
							end;
						end);
					end;
				end;
			end
		end;
	end;
end;

put this in a script directly under the Ui instance

you can add as many players as you like it just compiles them like in arsenal

for _, player in pairs(game:GetService('Players'):GetPlayers()) do
	if player:IsA('Player') then
		if player:FindFirstChild('leaderstats', false) then
			local leaderstats = player:FindFirstChild('leaderstats', false)
			if leaderstats:IsA('Folder') then
				if leaderstats:FindFirstChild('Kills', false) then
					local kills_val = leaderstats:FindFirstChild('Kills', false)
					if kills_val:IsA('ValueBase') then
						kills_val:GetPropertyChangedSignal('Value'):Connect(function()
							if player.Team == game:GetService('Teams'):FindFirstChild('Blue', false) then --// Enter your team name here
								tonumber(script.Parent:FindFirstChild('BlueTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text) += tonumber(kills_val.Value)
							elseif player.Team == game:GetService('Teams'):FindFirstChild('Green', false) then --// Enter your team name here
								tonumber(script.Parent:FindFirstChild('GreenTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text) += tonumber(kills_val.Value)
							end;
						end);
					end;
				end;
			end
		end;
	end;
end;

Try this then

this is the error i got back

for _, player in pairs(game:GetService('Players'):GetPlayers()) do
	if player:IsA('Player') then
		if player:FindFirstChild('leaderstats', false) then
			local leaderstats = player:FindFirstChild('leaderstats', false)
			if leaderstats:IsA('Folder') then
				if leaderstats:FindFirstChild('Kills', false) then
					local kills_val = leaderstats:FindFirstChild('Kills', false)
					if kills_val:IsA('ValueBase') then
						kills_val:GetPropertyChangedSignal('Value'):Connect(function()
							if player.Team == game:GetService('Teams'):FindFirstChild('Blue', false) then --// Enter your team name here
								script.Parent:FindFirstChild('BlueTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text = tonumber(script.Parent:FindFirstChild('BlueTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text) + tonumber(kills_val.Value)
							elseif player.Team == game:GetService('Teams'):FindFirstChild('Green', false) then --// Enter your team name here
								script.Parent:FindFirstChild('GreenTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text = tonumber(script.Parent:FindFirstChild('GreenTeamFrame', false):FindFirstChild(player.Name, false):FindFirstChild('Kills', false).Text) + tonumber(kills_val.Value)
							end;
						end);
					end;
				end;
			end
		end;
	end;
end;

try this oneeeeeeeeeeeeeeeee

thanks again for you help mate

image
From that error, is the script parented under this

before it is clone yes it is. once it is clone it is enabled and parented to the textlabel

local killscript = script.Parent.Killsscript:Clone()
killscript.Parent = PlayerImage2
killscript.Disabled = false

dont parent it to the text label. just leave it there

hey mate i tried it out

but nothing happened that time no update to the text label

Do you sir, by chance. Have discord?

sorry mate i dont lol im just a dad trying to make a game for my kids

Alright no issue, if you’re comfortable could you send me the place in DMs so I can just go through it. If not I can continue this back and forth.

here is another view

so the script create crwates the image label the parented textlabel to go in the teams frame when selected

Get rid of:
image
this as a whole…

and just enable the script at the end

ok cool will it still work if it is not parented to the textlabel?

That’s how I designed it, attempt it and lets see what happens

1 Like

bro you did it you are a genuis thank you very much it worked perfectly

That code should also work if your teams are greater than 1 per, it should just add the value to the current value. NOW that I think of it. You should probably change.

to just 1 because otherwise it’ll start adding 15 per then 16 per instead of counting up by one.