#How to get sum of value of all players
429 messages · Page 1 of 1 (latest)
show script
I think i have a code like you want somewhere in my projects
So you are trying to get the playtime correct?
game.Players.PlayerAdded:Connect(function(plr)
local Ticket = Instance.new("IntValue", plr)
Ticket.Name = "Ticket"
Ticket.Value = 0
end)```
lol
Roblox Assistant
HUH?
(decently new feature)
WHEN
is this good?
Well anyway I just want to get help in that thing
** You are now Level 7! **
Use RunService.Heartbeat to add +1 (second)
and format the ticket value if you want
local function formatTime(minutes)
local hours = math.floor(minutes / 60)
local remainingMinutes = minutes % 60
return string.format("%02d:%02d", hours, remainingMinutes)
end
Let me make it clear okay?
I think you do not know what I want
So, I making like a stand
With npc and when you click E by proxypropmt this fire event and then open a ui, when you click the button in that ui this adding you 1 to the value of the ticket. So, under the npc there is Surface gui, and inside there is textlabel so I want the TextLabel.Text = all the players ticket stats like if player1 has 5 ticket.value and player2 has 4 ticket.value then the text will be 9
So, why should I do ?
To get the sum of value of all the plrs
So kinda like a voting system\
You know the roblox talent show?
You could use a invoke server i believe toreduce chances of hackers abusing the remote event
Nah
I just need to finish this thing
Idk how to do it
I tried to do players:GetPlayers and get all the values but this not working /:
Let me make a quick small code for you
This is all serverscript untill i say its localscript
You can remove the if not ticketdata then if you already implemented the ticketdata.
** You are now Level 2! **
Bruh
PlayerGui? TicketUi?
Show me ur structure to your textlabel.
I just said I want to do
That
The text label in the sufrace gui
Which in workspace
Her text
Means the label.text will be
=
All the players ticket value
Sum of value of all players
So you want a total of all the players ticket value on a. Textlabel?
Yes
easy
You can loop thru alllll the players data folder (leaderstats) and look for the ticket value, add t hem up
is the value of tickets held under the player data
Loop?
** You are now Level 1! **
Yes
The player variable should reference your player location
local total = 0
for _, player in pairs(game.Players:GetPlayers()) do
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local ticketValue = leaderstats:FindFirstChild("ticket")
if ticketValue then
total = total + ticketValue.Value
end
end
end
print("Total tickets:", total)
what it should look like
i think
Tried
Not working
where are u storing ur variable
are you in a localscript?
For tickets
or a serverscript
Server
Are you storing it in leaderstats?
The ticket value under the plr
So you made a intvalue under the player
Yep
Then you won’t use leader stats to manipulate it lol
IDK
stop making it hard on us
Bruh
.
what are we supposed to do with the location of it
the part where you scan for the total or the players
are you sure this wont work?
local function calculateTotalTickets()
local totalTickets = 0
for _, player in pairs(game.Players:GetPlayers()) do
if player:FindFirstChild("Ticket") then
totalTickets = totalTickets + player.Ticket.Value
end
end
print("Total Tickets: " .. totalTickets)
end
game.Players.PlayerAdded:Connect(function(plr)
local Ticket = Instance.new("IntValue", plr)
Ticket.Name = "Ticket"
Ticket.Value = 0
calculateTotalTickets()
end)
game.Players.PlayerRemoving:Connect(function()
calculateTotalTickets()
end)
I do not want to print it
the print is simply for testing
Then update the text with the total…
if he wants whent he value is changed then add a
Ticket:GetPropertyChangedSignal("Value"):connect(function()
---.......
end)
Yes
I’m not gonna baby you with the answer I’ve given you the hardest part lol now just reference ur gui
real
how tthe crust are you scripter?
:
Your acting like I’m some kinda robot here to fine tune ur script
💀
I apologize for the misunderstanding.
@meager sunSo what happend?
I eating fish rn
Bruh
You know RTS?
@last wing @clear quest @last wing
?, no
what
Check out Roblox Talent Show ❄️🎄. It’s one of the millions of unique, user-generated 3D experiences created on Roblox. 🎤 Step into the world of Roblox Talent Show, the largest and most innovative talent competition game on the Roblox platform! Show your skills to the Judges and earn a rating based on your performance!
Within Roblox Talent Show,...
i forgot i was in this thread
You know it?
no
When you start
You have to take a number
a "Tag"
Then
You see on ur shirt the tag
And on the sign the next number
You can take
So we want to know how to count all the players value in server
Got it?
yeah he sent u the code
** You are now Level 3! **
Who?
juzza
This?
yes, since our limited knowledge of the code, execpt the tickets he could only make this to help you i guess
Listen to this @unique plume
He wants when it changes
Listen to the voice note
You say that every time you click its add 1
so
He dosent need to take the sum value?
One sec we are trying
No cause if you add one it will make its own sum lol
Just make sure to add it to the variable you made
local tickets = 1
If click then
Tickets += 1
Basic pseudo code
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.GetNumberOfTag
game.Players.PlayerAdded:Connect(function(plr)
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
local Ticket = Instance.new("IntValue", plr)
Ticket.Name = "Ticket"
Ticket.Value = 0
end)
remote.OnServerEvent:Connect(function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
if PlayerTicket then
PlayerTicket = PlayerTicket.Value + 1
PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
game.Workspace.GetTag.SurfaceGui.TextLabel.Text = PlayerTicket.Value
end)
end
end
end)```
server script
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.GetNumberOfTag
local btn = script.Parent
local frame = game.StarterGui.MainInterface.TagSelectFrame
btn.MouseButton1Click:Connect(function(plr)
local TweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local Goal = {}
Goal.Position = UDim2.new(0.5, 0, 1, 115)
local tween = game:GetService("TweenService"):Create(frame, TweenInfo, Goal)
tween:Play()
remote:FireServer(plr)
end)```
local script
Use invokeserver if you want to get info from a localscript
since thats the purpose of a remotefunction
and much better than a remotefunction
wait invoke server is it a remote function
so why you said much better than a remote function
:-;
I mean they are better than remote events
since they are made mostly to retrieve information
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
game.Players.PlayerAdded:Connect(function(plr)
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
local Ticket = Instance.new("IntValue", plr)
Ticket.Name = "Ticket"
Ticket.Value = 0
end)
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
SurfaceGui.TextLabel.Text = PlayerTicket.Value
end
end)
end
end
end```
so
this is the server script
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
local btn = script.Parent
local frame = game.StarterGui.MainInterface.TagSelectFrame
btn.MouseButton1Click:Connect(function()
local TweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local Goal = {}
Goal.Position = UDim2.new(0.5, 0, 1, 115)
local tween = game:GetService("TweenService"):Create(frame, TweenInfo, Goal)
tween:Play()
remote:InvokeServer()
end)```
this is local script
I did t by a remote function
And still
not working /:
SERVERSCRIPT
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
return PlayerTicket.Value
end
end)
end
end
end
PART.TOUCHED????????
Why fire clients
mb combined 2 scripts
localscript
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
local btn = script.Parent
local frame = game.StarterGui.MainInterface.TagSelectFrame
btn.MouseButton1Click:Connect(function()
local TweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local Goal = {}
Goal.Position = UDim2.new(0.5, 0, 1, 115)
local tween = game:GetService("TweenService"):Create(frame, TweenInfo, Goal)
tween:Play()
local Information = remote:InvokeServer()
TextLabel.Text = tostring(Information)
end)
** You are now Level 4! **
You must not know how a rmeotefunction work do you?
look it up on docs
I kinda know you just invoke server and then in the server creating function but what is the information
how can I pass it ;-;
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter" --passing this information
else
InRound.Value = true
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
return PlayerTicket.Value --Passing this information
end
end)
end
end
end
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter" -- Return a string indicating the reason
else
InRound.Value = true
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
-- Connect a function to the PropertyChangedSignal
local ticketChangedConnection
ticketChangedConnection = PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
-- Check if the SurfaceGui exists
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
-- Disconnect the event to avoid memory leaks
ticketChangedConnection:Disconnect()
-- Return the updated PlayerTicket.Value
return PlayerTicket.Value
end
end)
end
end
return "Unable to process request"
end
``` made this abit more complicated
but same thing
i would recommend using this
But then the text written in local scripts
isn't my job to write it for all the server?
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
local btn = script.Parent
local frame = game.StarterGui.MainInterface.TagSelectFrame
local TextLabel = frame:WaitForChild("TextLabel")
btn.MouseButton1Click:Connect(function()
local TweenInfo = TweenInfo.new(0.6, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local Goal = {}
Goal.Position = UDim2.new(0.5, 0, 1, 115)
local tween = game:GetService("TweenService"):Create(frame, TweenInfo, Goal)
tween:Play()
local Information = remote:InvokeServer()
-- Update the TextLabel directly with the returned information
TextLabel.Text = tostring(Information)
end)
What do you mean?
yes
but I need the text to be write in server
why?
debug it and some prints to see where it went wrong
k
I would never use invokeserver in case someone lags out or leaves before the server invokes it could cause a infinite yield
What else would you use?
idk I trying whatever you offer me lol
remote event would work
Usually if you can’t do it with conditions of remote events it’s not worth it
but worry about hackers
then add a checking system
hackers don’t exist anymore
blah blah blah
lol
they kinda do
not on pc atleast
ive heard they use mobile emulators
Nope they added Byron to mobiles
to make e xploits
today?
That was a bypass ages ago
No
That was a bypass ages ago as I said
not really
The only exploit rn is a AI aimbot
** You are now Level 3! **
YEAH BECAUSE SYNAPSE X
Nah they will block cheats in all platforms
even in xbox lol
How to Exploit on PC : https://youtu.be/7cBWk4jMNcE
Best Working Free Executor : https://youtu.be/omilO4k4WMM
How to Get Codex Key : https://youtu.be/kq9G6rBivtk
▬▬▬▬▬▬▬▬▬
Download Scripts : https://robloxscripts.net/
FREE MOBILE EXECUTOR : https://codex.lol/
Giveaways & Support at https://discord.gg/robloxexploits
▬▬▬▬▬▬▬▬▬
[🎁GIFT] Roblox Bl...
Found this
they still work on mobile emulators
not on pc or stuff
I love people sending virus YouTube videos as evidence
LOL
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
print("1")
if InRound.Value == true then
print("2")
return "Can not enter" -- Return a string indicating the reason
else
InRound.Value = true
print("3")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("4")
-- Check if the SurfaceGui exists
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
print("5")
if SurfaceGui then
print("6")
-- Return the updated PlayerTicket.Value
return PlayerTicket.Value
end
end
end
return "Unable to process request"
end
juzza you got any ideas how to fix it?
like these prints?
huh
i already told you something random
** You are now Level 5! **
you can see there on mobilke
mobile
on the right side
They are literally downloading the app on pc
It’s a virus video
the video dont matter
about the downloads
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
game.Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
local Ticket = Instance.new("IntValue", plr)
Ticket.Name = "Ticket"
Ticket.Value = 0
if Ticket then
print("2")
end
end)
remote.OnServerInvoke = function(player)
print("3")
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
print("4")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("5")
local ticketChangedConnection
ticketChangedConnection = PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
print("6")
ticketChangedConnection:Disconnect()
print("7")
return PlayerTicket.Value
end
end)
end
end
return "Unable to process request"
end```
and the localscript?
not working lol
they aint patched bruh
just get a mobile emulator
and install a executer
done
did you print the information?

ok
** You are now Level 8! **
so
infomation = Unable to process request
this writed in the text
instead of the number this
alright
and it said information is this because you did if it is not working so it will retrurn it
rip script
2 hours old
changed - SO MUCH TIMES
Working - Hell nah
remote.OnServerInvoke = function(player)
local InRound = player:WaitForChild("InRound")
local PlayerTicket = player:WaitForChild("Ticket")
print("Checking conditions for player:", player.Name)
if InRound.Value == true then
print("Condition 1 met: Can not enter")
return "Can not enter"
else
InRound.Value = true
print("Condition 1 not met: Setting InRound to true")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("Condition 2 met: Incrementing PlayerTicket")
return PlayerTicket.Value
else
print("Condition 2 not met: PlayerTicket does not exist")
end
end
warn("Unexpected condition: Unable to process request")
return "Unable to process request"
end
bruh added any print he cans think about
20:23:30.253 Condition 1 not met: Setting InRound to true - Server - ServerTag:31
20:23:30.253 Condition 2 met: Incrementing PlayerTicket - Server - ServerTag:35
Ok so that is good
that means the return PlayerTicket.Value has been reached
did u get a print from the localscript?
sorry I like Ronaldo lol
me to o
try testing it out in a 2 player game or a 3 player game
if the ticket value is set to 0 like normal it should be 3
oh yes
bruh
so
I was right
because you did that
label.text = information
in the client
so 2 players
can not see the other number
I tested it with my friend
he sees 1 when he clicked
but I see 0
;-;
ofcourse
cuz the ticket is in the player
you can either store a local variable or add a int value in serverstorage or serverscriptservice
choose which one
ok
did u do it?
yes
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
game.Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
end)
remote.OnServerInvoke = function(player)
print("3")
local InRound = player:WaitForChild("InRound")
local PlayerTicket = game:GetService("ServerStorage").TicketCount
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
print("4")
if PlayerTicket then
PlayerTicket = PlayerTicket+ 1
print("5")
local ticketChangedConnection
ticketChangedConnection = PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
print("6")
ticketChangedConnection:Disconnect()
print("7")
return PlayerTicket.Value
end
end)
end
end
return "Unable to process request"
end
this is the server script
ohh
oh
game.Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
end) why?
cuz the ticket value in the player is the problem why
cuz its returning the PLAYER'S ticket value
lemme test
20:41:20.164 ServerScriptService.ServerTag:23: attempt to perform arithmetic (add) on Instance and number - Studio
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
game.Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
end)
remote.OnServerInvoke = function(player)
print("3")
local InRound = player:WaitForChild("InRound")
local PlayerTicket = game:GetService("ServerStorage").TicketCount
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
print("4")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("5")
local ticketChangedConnection
ticketChangedConnection = PlayerTicket:GetPropertyChangedSignal("Value"):Connect(function()
local SurfaceGui = game.Workspace.GetTag.SurfaceGui
if SurfaceGui then
print("6")
ticketChangedConnection:Disconnect()
print("7")
return PlayerTicket.Value
end
end)
end
end
return "Unable to process request"
end
20:43:14.347 ServerScriptService.ServerTag:23: attempt to perform arithmetic (add) on string and number - Studio
still
there
ohhh because the space
same error lol
oh
lol
sec
testing
20:46:07.636 Unable to process request - Client - LocalScript:16
local Players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local remote = rs.Remotes.RemoteFunction
game.Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
end)
remote.OnServerInvoke = function(player)
print("3")
local InRound = player:WaitForChild("InRound")
local PlayerTicket = game:GetService("ServerStorage").TicketCount
if InRound.Value == true then
return "Can not enter"
else
InRound.Value = true
print("4")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("5")
print("6")
print("7")
return PlayerTicket.Value
end
end
return "Unable to process request"
end
try this
here
blud
??
yeah its most likely because of the screengui and the changepropertysignal
because when the remote function got ran it was waiting for a change in the value.
lemme test with 2 players
not showing me when my friend clicked
;-;
oh wait
there is an error
sec sec
something happend sec
listen
I tested it with my friend
he clicked I saw still 0
and he saw 1
and when I clicked
I saw 2
and he saw still 1
send the error message
hmm try this not sure if this will work
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage.Remotes.RemoteFunction
Players.PlayerAdded:Connect(function(plr)
print("1")
local InRound = Instance.new("BoolValue", plr)
InRound.Name = "InRound"
InRound.Value = false
end)
remote.OnServerInvoke = function(player)
print("3")
local InRound = player:WaitForChild("InRound")
local PlayerTicket = game.ServerStorage:WaitForChild("TicketCount") -- Make sure TicketCount is a child of ServerStorage
if InRound.Value then
return "Cannot enter, already in round"
else
InRound.Value = true
print("4")
if PlayerTicket then
PlayerTicket.Value = PlayerTicket.Value + 1
print("5")
print("6")
print("7")
return PlayerTicket.Value
end
end
return "Unable to process request"
end
