Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to locate stats that are not in leaderstats? (Edited)

Ok so my shop is finally working yeah! But we have a problem with adding money to people, instead of it using leaderstats as a way (this is so hackers can't hack they stats) to change it uses a Folder in ServerScriptServices called Players and it adds new Folders with their Username with the stat inside but I have no idea how to locate that from a script so it can change. Here's the script I'm trying to change my leaderboard money with.

local time = 180

while true do
	wait(1)
	time = time - 1
	if (time <= 0) then
		time = 180
		players = game.Players:GetChildren()
		for i=1, #players do
			if (players[i]~=nil) then
				if (players[i]:findFirstChild("leaderstats")) then
					if (players[i].leaderstats:findFirstChild("Credits")) then
						if (players[i]:IsInGroup(234707)==true) then -- user IS in ERR
							players[i].leaderstats.Credits.Value = players[i].leaderstats.Credits.Value + 50
							if (players[i]:IsInGroup(234706)==true) then -- Guard
								players[i].leaderstats.Credits.Value = players[i].leaderstats.Credits.Value + 30
							end
						else
							players[i].leaderstats.Credits.Value = players[i].leaderstats.Credits.Value + 50
						end
					end
				end
			end
		end
	end
	playersa = game.Players:GetChildren()
	for i=1, #playersa do
		if (playersa[i]~=nil) then
			if (playersa[i]:findFirstChild("PlayerGui")) then
				if (playersa[i].PlayerGui:findFirstChild("PaydayGui")) then
					playersa[i].PlayerGui.PaydayGui.Label.Text = "Next payday in: " .. tostring(time) .. " seconds"
				end
			end
		end
	end
end

2 comments

0

Sorry, but this is really confusing. Break it up a little, and leave some code snippets for us to work off of.

0

I have Edited

1 answer

✓ Accepted answer

All you have to do is change the source of where you're editing the stats, silly. It's on lines 14,16,and 19

I edited some other stuff too for efficiency(;

local time = 180

while wait(1) do
	time = time - 1
	if (time <= 0) then
		time = 180
	end
	for i,v in pairs(game.Players:GetPlayers()) do
		--different source directory
		local plr = game.ServerScriptStorage.Players:FindFirstChild(v.Name)
		if plr then
			--edit--
			local gui = v.PlayerGui:FindFirstChild('PaydayGui')
			--edit--
			local creds = plr.Credits
			if gui then
				gui.Label.Text = 'Next payday in '..time..' seconds'
			end
			if plr:IsInGroup(234707) then
				creds.Value = creds.Value + 50
			elseif plr:IsInGroup(234706) then
				creds.Value = creds.Value + 30
			end
			creds.Value = creds.Value + 50
		end
	end
end

4 comments

0

Thank you!

0

PlayerGui is trying to be found in the folder it self not in normal Players instact how I can I find it?

0

Oh my bad, since we're iterating through a table of all the players with a generic for loop then you can just use 'v' as the player and get the PlayerGui through there(: I'll edit my answer though.

0

Thanks!

This discussion is preserved as it was. New answers, comments, and votes are closed.