|
| 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 |
|
|
| |
|
smurf279
|
  |
| Joined: 15 Mar 2010 |
| Total Posts: 6871 |
|
|
| 15 Dec 2011 06:58 PM |
| game.Players:GetPlayers()[1] |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 15 Dec 2011 07:00 PM |
| Sorry, didnt see your reply we posted at the same time... let me try that... |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 15 Dec 2011 07:39 PM |
| K, I'm going to repost in a different thread |
|
|
| Report Abuse |
|
|