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 » Scripting Helpers
Home Search
 

game.Players Help needed

Previous Thread :: Next Thread 
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 06:31 PM
How do I reference the first child in the players list in a line of code?

I get as far as game.Players. and then I am at a loss for what to type.

thx,

Fireheart
Report Abuse
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 06:51 PM
Help still needed...
Report Abuse
smurf279 is not online. smurf279
Joined: 15 Mar 2010
Total Posts: 6871
15 Dec 2011 06:58 PM
game.Players:GetPlayers()[1]
Report Abuse
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 06:59 PM
Alright let me rephrase the question, how to I refer to the to the first player in the player list?
Report Abuse
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 07:00 PM
Sorry, didnt see your reply we posted at the same time... let me try that...
Report Abuse
onetimeaccount123 is not online. onetimeaccount123
Joined: 20 Oct 2011
Total Posts: 189
15 Dec 2011 07:05 PM
I imagine that what you have in mind is that the first person to join gets something special, some type of condition, some thank you message, ect. For this you don't need much. You just need to make a script that either activates when the server starts then deletes itself after everything is done or you need something that detects when the # of players isn't 0. There are many other ways to do this. I think that the things shown in the player list are in alphabetical order so if you want the first thing that comes in the alphabet I can't really help with that. Sorry I'm a beginning scripter myself.
Report Abuse
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 07:31 PM
No this is not what I want.

I am making a Black Ops Zombies Kino Der Toten game, and I want it to take away the players money if they have it and give them a quick revive bottle, here is my script:

local debounce = false

function getPlayer(humanoid)
local players = game.Players:children()
for i = 1, #players do
if players[i].Character.Humanoid == humanoid then return players[i] end
end
return nil
end
hint = Instance.new("Hint")
function onTouch(part)

local human = part.Parent:findFirstChild("Humanoid")
if (human ~= nil) and debounce == false then

debounce = true
hint.Parent = game.Workspace
hint.Text = ""
local player = getPlayer(human)

if (player == nil) then return end

script.Parent:FindFirstChild("Heal(100%)"):clone().Parent = player.Backpack -- Change "TOOL" with the name of your tool

wait(4) ---the time in which the tool can be gave again
debounce = false
hint.Parent = nil
end
end


local player = game.Players:GetPlayers()[1]
local playerMoney = player.leaderstats.Money.Value

if playerMoney >= 100 then

script.Parent.Touched:connect(onTouch)
newMoney = playerMoney - 100
playerMoney = newMoney

end

This gives the player the bottle but does not take away the money, (so i believe, I have not tried it out on a live server, I will post when I have), can anyone help with this now?
Report Abuse
fireheart568 is not online. fireheart568
Joined: 04 Jan 2009
Total Posts: 1285
15 Dec 2011 07:39 PM
K, I'm going to repost in a different thread
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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