I’ve been thinking about what would be the best way to make a number increase by 1 every time a DButton is pressed and then send this new number back to every client.
I’ve been able to brainstorm a few ideas but have had no luck. These are my most *sensible *ideas I’ve got so far:
I’ve been able to try a rough version of the idea on the left, but had no luck on completing it as I’ve drawn a blank. The monstrosity of my thought process turning into code after watching a very heated debate on Question Time was this:
// The Button Join.DoClick = function () net.Start("Imin") net.WriteInt(1) net.SendToServer() DermaBob:Remove() end // The number changing Count.Think = function( nself ) net.Receive("Imin") net.ReadString() nself:SetText( attendees ) end // Server util.AddNetworkString("Imin") local attendees = 0 net.Receive("Imin") local Iminers = net.ReadInt() local attendees += Iminers net.Start("Imin") local net.WriteString(attendees) net.Broadcast()
I’m aware there are multiple disasters in this code such as me adding the two variables incorrectly or converting the integer into a string and the various other failures. Just hoping for an opinion on the best way to be doing it before I continue to attempt. No need for spoon feeding
Big thanks in advance, (and sorry for my catastrophe of a brain storm)
For reference if anyone is intrested ive used (and tried using) as there relevant to what I’m doing