JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 20 Jan 2016 04:09 PM |
In me game there is a leaderboard with Kills and Wins
How would you put it into another script "Main game Script" that when you win the game, you're given a win? |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 04:27 PM |
| Dill make this for you for 590 robux |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
| |
|
|
| 20 Jan 2016 04:51 PM |
| player.leaderstats.Wins.Value = (player.leaderstats.Wins.Value + 1) |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
| |
|
FrostOver
|
  |
| Joined: 20 Jun 2013 |
| Total Posts: 299 |
|
|
| 20 Jan 2016 10:14 PM |
| you need to create a value called wins first, did you think it was automatically there? |
|
|
| Report Abuse |
|
|
| |
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 20 Jan 2016 10:17 PM |
^ yea I had this above it player = getTeamPlayers("Bright red")[1].Name player.leaderstats.Wins.Value = (player.leaderstats.Wins.Value + 1) |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 10:21 PM |
Remove the .Name when you define the player, you need the player object not just the players name.
Also keep in mind this method will declare a random person a winner if time runs out because it just says first player in table wins
Just make sure to check if there are 2 players on the red team before saying they win. |
|
|
| Report Abuse |
|
|
WoolHat
|
  |
| Joined: 19 May 2013 |
| Total Posts: 1873 |
|
|
| 20 Jan 2016 10:22 PM |
| Not sure how your getteamplayers function works, but you're trying to index the string of a player's name, as opposed to the Player. |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 10:26 PM |
I wrote the function it works like this
local function getTeamPlayers(teamColor, neutral) local output = {} for _, player in next, game.Players:getPlayers() do if ((player.TeamColor.Name == teamColor) and (neutral or (not player.Neutral))) then table.insert(output, player) end end return output; end |
|
|
| Report Abuse |
|
|
|
| 20 Jan 2016 10:27 PM |
'kay:
Script 1:
local Players = game:GetService("Players") function onPlayerAdded(player) local Wins = Instance.new("NumberValue") Wins.Name = "Wins" Wins.Parent = player local Kills = Instance.new("NumberValue") Kills.Name = "Kills" Kills.Parent = player end Players.PlayerAdded:connect(onPlayerAdded)
Script 2:
Somehow find the player, so in a "Hit" script:
function onTouch(hit) local player = hit.Parent.Name local testplayer = game.Players:FindFirstChild(player) if testplayer ~= nil then game.Players[player].Wins.Value = game.Players[player].Wins.Value + 1 end end
script.Parent.Touch:connect(onTouch)
It's just roblox, deal with it. |
|
|
| Report Abuse |
|
|
JustScary
|
  |
| Joined: 03 Sep 2015 |
| Total Posts: 1765 |
|
|
| 20 Jan 2016 10:30 PM |
I fixed it after you said remove .Name part of it.
Thanks all for the help!
It was so obvious too lmao |
|
|
| Report Abuse |
|
|