Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 30 Jan 2016 03:11 PM |
function declareLoser() local winners = "" local players = game:GetService("Players"):GetPlayers(); local msg = Instance.new("Message", game:GetService("Workspace")); msg.Text = owner.Value.Name.." was the loser!"; wait(2); msg:Destroy(); if players["Character"]:findFirstChild("Alive") ~= nil then winners = winners.." "..players.Name.."" if players:findFirstChild("leaderstats") ~= nil then players.leaderstats.Wins.Value = players.leaderstats.Wins.Value + 1 end end end;
|
|
|
| Report Abuse |
|
|
|
| 30 Jan 2016 03:15 PM |
Yeah you have to do remotefunctions/events if you're going to use FE otherwise it won't work.
http://wiki.roblox.com/index.php?title=API:Class/RemoteFunction |
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 30 Jan 2016 03:16 PM |
| It works on FE but this portion of code isnt (server sided) |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2016 03:16 PM |
So you just drop a random script onto a forum post without context, ask a simple question in the title, and give us absolutely zero background context on the script's location in the server, whether it's local, global, or part of a module, or even the REST OF THE SCRIPT THAT TRIGGERS THE FUNCTION declareLoser()! Give us some background and then we may be able to come up with a solution.
|
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 30 Jan 2016 03:19 PM |
No Errors or any output, Its in serverscriptservice and its a global script, and its fired by:
function initRound() pickMap(); loadCharacters(); startTimer(roundTime); declareLoser(); end;
wait(.2); while true do if game:GetService("Players").NumPlayers >= 2 then initRound(); else wait(); end; end; |
|
|
| Report Abuse |
|
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
|
| 30 Jan 2016 03:26 PM |
OnServerInvoke*
function RemoteFunction.OnServerInvoke(player, name) print("example", player.Name) return player.Name end |
|
|
| Report Abuse |
|
|
|
| 30 Jan 2016 03:27 PM |
| I don't think he understands this. I don't see what the problem is, though. |
|
|
| Report Abuse |
|
|
| |
|
|
| 30 Jan 2016 03:30 PM |
At the bottom you're treating the "players" variable, which is a table containing all players, like it's an instance.
if players["Character"]:findFirstChild("Alive") ~= nil then winners = winners.." "..players.Name.."" if players:findFirstChild("leaderstats") ~= nil then players.leaderstats.Wins.Value = players.leaderstats.Wins.Value + 1
You need to run this code iterating over every single player. I'll try to redo it so it works. |
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
|
| 30 Jan 2016 03:45 PM |
Ive got this now; but its not giving the + 1 to the wins*
function declareLoser() local winners = "" local players = game:GetService("Players"):GetPlayers(); local msg = Instance.new("Message", game:GetService("Workspace")); msg.Text = owner.Value.Name.." was the loser!"; wait(2); msg:Destroy(); for i = 1, #players do if players[i]["Character"]:findFirstChild("Alive") ~= nil then winners = winners.." "..players[i].Name.."" if players[i]:findFirstChild("leaderstats") ~= nil then players[i].leaderstats.Wins.Value = players[i].leaderstats.Wins.Value + 1 end end end end; |
|
|
| Report Abuse |
|
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
Link5659
|
  |
| Joined: 04 Jun 2012 |
| Total Posts: 4525 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 31 Jan 2016 12:52 PM |
I reformatted your code. Get rid of all the useless semicolons, parentheses, etc. Make it look clean.
function declareLoser() local winners = "" local msg = Instance.new("Message", workspace) msg.Text = owner.Value.Name.." was the loser!" wait(2) msg:Destroy() for i,v in next, game.Players:GetPlayers() do if v.Character["Alive"] then winners = winners.." "..v.Name local stats = v:WaitForChild("leaderstats") v.Wins.Value = v.Wins.Value + 1 end end end |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 31 Jan 2016 12:53 PM |
| Also, winners and winners will override eachother. You need to change the names |
|
|
| Report Abuse |
|
|