onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 16 Aug 2014 06:55 PM |
Hello everyone! I have been dealing with this for a while now, but it's really creating problems for me. In Studio, I will have a GUI(s) that has script in it, such as a player count, and it will work flawlessly when I test it in studio, however, when I save it and play the game, the scripts in the GUI(s) do not work. I'm not sure why this is happening, but it's really getting in the way of making my game. If anybody can explain this, I would highly appreciate it if they do so. Thanks for reading!
-- Yes the scripts do work, I have tested various scripts to do several things, and they will work perfectly fine in the test, they just don't work in the game after I publish it and play it regularly in a public server. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
| |
|
|
| 18 Aug 2014 01:00 AM |
| Could you show us the script?, there's multiple reasons as to why this could be occurring. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 03:33 AM |
txt = script.Parent function updateGUI() local players = game.Players:getPlayers() if #players == 1 then txt.Text = "# of players in this server: ".. #players .."" elseif #players > 1 then txt.Text = "# of players in this server: ".. #players .. "" end end
updateGUI() game.Players.ChildAdded:connect(updateGUI) game.Players.ChildRemoved:connect(updateGUI)
--------------------------------------------------------------------------- This is one of the scripts that works like a charm when testing, but doesn't work after being published. 0 scripts work when they're inside a GUI. Also, this script is not disabled. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 03:48 AM |
| Also, the forum filtered out the spaces in the script, so the spacing isn't the same as how it actually is. |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 03:53 AM |
| Could you also describe the hierarchical order of the objects?. |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 06:31 AM |
txt = script.Parent function updateGUI() local players = game.Players.NumPlayers txt.Text = "# of players in this server: "..players end |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 07:00 AM |
Objects: Game > StarterGui > [ScreenGui] > [ScreenGui] > [TextLabel] > [Script] --- |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 07:11 AM |
| Did you even try my script? |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 08:51 AM |
| No it did not work, local or server. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 08:54 AM |
| Okay it's 6:53 am and I have not slept, so I'm going to sleep a little then come back to check on new posts. Goodnight everyone! |
|
|
| Report Abuse |
|
|
blocco
|
  |
| Joined: 14 Aug 2008 |
| Total Posts: 29474 |
|
|
| 18 Aug 2014 09:21 AM |
LocalScripts run on the client. Scripts run on the server.
Be sure that, since your PlayerGui [del]will not[/del] [ins]should not[/ins] replicate to the server, the code must run on the client. Use LocalScripts for GUI stuff. |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 09:27 AM |
while wait() do player = players:GetChildren() script.Parent.Text = "No. of players: " .. tonumber(#players) end
I found an origin, it was Skeletal. |
|
|
| Report Abuse |
|
|
|
| 18 Aug 2014 09:28 AM |
while wait() do players = game.Players:GetChildren() script.Parent.Text = "No. of player: " .. tonumber(#players) end
Sorry I'm also tired xD
I found an origin, it was Skeletal. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 10:22 PM |
| Thank you so much, blocco!! I did what you said, and it works perfectly! I have no idea why I didn't already think of that. Thanks so much, I have been dealing with this problem for ever lol. |
|
|
| Report Abuse |
|
|
onion97
|
  |
| Joined: 22 Jun 2008 |
| Total Posts: 64 |
|
|
| 18 Aug 2014 10:38 PM |
| Thank you so much, blocco!! I did what you said, and it works perfectly! I have no idea why I didn't already think of that. Thanks so much, I have been dealing with this problem for ever lol. |
|
|
| Report Abuse |
|
|