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
 

Re: Getting a character from Player

Previous Thread :: Next Thread 
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:03 AM
I.e.
x = game.Players.whateveritishere
for loop here
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:05 AM
http://wiki.roblox.com/index.php/GetPlayerFromCharacter
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:06 AM
Wait so it works both ways, in that if I do

player = game.Players:GetPlayerFromCharacter(character)

"character" is the players character?
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
05 Jun 2013 10:07 AM
local Character = game.Players.PlayerHere.Character
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:08 AM
Yes
local character = Workspace.Jammintoad
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:09 AM
So, would this work.

theguis = game.Players:GetPlayerFromCharacter(character)
for i = 1, #theguis do
if theguis[i].character.PlayerGui.Map1 ~= nil then
theguis[i].character.PlayerGui.Map1.TeleportButton.Text = "Destroying..."
end
end
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:10 AM
Sorry, from reading your post I was thinking you wanted to get the player from character

local = game.Players:GetChildren()
for i = 1, #p do
char = Workspace:FindFirstChild(p[i])
print(char.Name)
end
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:11 AM
^
local p = game.Players:GetChildren()
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:12 AM
What if the player died, then wouldn't the Player's character not exist in workspace and break the script?
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:12 AM
char = Workspace:FindFirstChild(p[i].Name)

Sorry :(
Report Abuse
batistapowerbonbtla is not online. batistapowerbonbtla
Joined: 16 Dec 2011
Total Posts: 2203
05 Jun 2013 10:13 AM
The character still exists in workspace when they die, but not when respawning
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:15 AM
Right, so what if it runs while they respawn. ._.
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:21 AM
Ugh I'm pathetic. Where do I find the GUIs that are currently in a character?
Ex: char = Workspace:FindFirstChild(p[i].Name)
if char.PlayerGui.Map1 ~= nil then
char.PlayerGui.Map1.TeleportButton.Text = "Destroying...
Report Abuse
MrChubbs is not online. MrChubbs
Joined: 14 Oct 2010
Total Posts: 4969
05 Jun 2013 10:25 AM
local players = game.Players:GetChildren()
for _,v in pairs(Players) do --_ being the index, v being the object
character = v.Character --Player is a propery of character
guiHolder = v.PlayerGui --PlayerGui is also a child of player, not character
if guiHolder:findFirstChild("Map1") then --If it doesn't equal nil
guiHolder.Map1.TeleportButton.Text = "Destroying...
end
end
Report Abuse
Jammintoad is not online. Jammintoad
Joined: 08 Feb 2009
Total Posts: 10239
05 Jun 2013 10:30 AM
Thank you good sir!
Report Abuse
cpbuilderman is not online. cpbuilderman
Joined: 10 Sep 2010
Total Posts: 2586
05 Jun 2013 10:53 AM
Player.Character

Character contains you actual character. The one in workspace. Not visible but works ;)

swagmiester
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