Why isn't this GUI giver working properly with more than 1 player in the server?
Asked by
8 years ago Edited 8 years ago
Hello there. This system is meant to be that when you step on it, it gives you a GUI that counts down and when it reaches 0, it gives you the money then deletes it self. This works while playing alone, however... when there's another player in the server, it gets stuck at 14 on the countdown, until the other player steps on the pad as well. Then it continues to countdown, until it reaches 1. It gives the money but doesn't delete the GUI, like it does solo.
Layout:
http://prntscr.com/bvajfp
Main Script:
08 | players = game.Players:GetChildren() |
10 | if (players [ i ] :findFirstChild( "leaderstats" )) then |
11 | players [ i ] .leaderstats.Money.Value = players [ i ] .leaderstats.Money.Value + 30000 |
12 | script.Parent:Destroy() |
17 | playersa = game.Players:GetChildren() |
19 | playersa [ i ] .PlayerGui.FlashGUI.text.Text = "You will recieve the money in: " .. tostring (time) |
GUI Giver script, located in head:
02 | function getPlayer(humanoid) |
03 | local players = game.Players:children() |
05 | if players [ i ] .Character.Humanoid = = humanoid then return players [ i ] end |
12 | local human = part.Parent:findFirstChild( "Humanoid" ) |
13 | if (human ~ = nil ) and debounce = = false then |
17 | local player = getPlayer(human) |
19 | if (player = = nil ) then return end |
21 | script.Parent.Parent:findFirstChild( "FlashGUI" ):clone().Parent = player.PlayerGui |
29 | script.Parent.Touched:connect(onTouch) |