generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: If you can do this

Previous Thread :: Next Thread 
JustScary is not online. 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
checkplate is not online. checkplate
Joined: 05 Jan 2016
Total Posts: 1379
20 Jan 2016 04:27 PM
Dill make this for you for 590 robux
Report Abuse
JustScary is not online. JustScary
Joined: 03 Sep 2015
Total Posts: 1765
20 Jan 2016 04:49 PM
lmao nah
Report Abuse
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 04:51 PM
player.leaderstats.Wins.Value = (player.leaderstats.Wins.Value + 1)
Report Abuse
JustScary is not online. JustScary
Joined: 03 Sep 2015
Total Posts: 1765
20 Jan 2016 10:12 PM
^ didnt work
Report Abuse
FrostOver is not online. 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
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
20 Jan 2016 10:14 PM
Did you define player?
Report Abuse
JustScary is not online. 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
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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 is online. 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
128Gigabytes is not online. 128Gigabytes
Joined: 17 Apr 2014
Total Posts: 3616
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
FireController1847 is not online. FireController1847
Joined: 17 Jan 2013
Total Posts: 1828
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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image