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: Shortest way to get the player.

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
07 May 2014 04:25 AM
It must be a Script and cannot contain the word "Player" (That includes Player, Player1, Players, etc.)
The Script is a descendent of of the player, but you don't know how many parents it would take to find the player!



No global variables.

No Module or Local scripts.

It must work, and return the player

It has to be a function (names count as part of script)

It can't have errors.



That is about it, goodluck :D
Report Abuse
CarlosMX is not online. CarlosMX
Joined: 30 Apr 2011
Total Posts: 791
07 May 2014 05:11 AM
Is this like a competition, or a request??
Report Abuse
Jonibus is not online. Jonibus
Joined: 30 Jan 2010
Total Posts: 8985
07 May 2014 05:25 AM
A competition, he always posts them here rather than the scripting forum

Follow me on twitter: @Jonibus_RBX
Report Abuse
jasondee1 is not online. jasondee1
Joined: 26 Jul 2008
Total Posts: 8002
07 May 2014 05:47 AM
Tries to find a "backpack" first, if its in the "player", else it will look for a "humanoid", if it is in the character. Searches 3 parents up.




function findplayer()

bin = script.Parent
binbin = bin.Parent
binbinbin = binbin.Parent

local foundplayereasy = bin:FindFirstChild("Backpack")

local foundplayermedium = binbin:FindFirstChild("Backpack")

local foundplayerhard = binbinbin:FindFirstChild("Backpack")

local doitthehardway = bin:FindFirstChild("Humanoid")

local doitthehardwayx2 = binbin:FindFirstChild("Humanoid")

local rage = binbinbin:FindFirstChild("Humanoid")

if foundplayereasy then
wait(1)
print("THAT WAS EASY")
script.Disabled = true
else
print("So you want to play it the hard way huh?")
wait(3)
end

if foundplayermedium then
wait(1)
print("YO WE FOUND THE PLAYER")
script.Disabled = true
else
print("Grrrrr....")
wait(3)
end

if foundplayerhard then
wait(1)
print("I FINALLY HAVE MY HANDS ON YOU")
script.Disabled = true
else
print("WHOEVER YOU ARE. I WILL FIND YOU")
wait(3)
end

if doitthehardway then
wait(1)
print("After all these years....")
script.Disabled = true
else
print("This calls for EXXTRREEEEME MEEASSUURREEESSS")
wait(5)
end

if doitthehardwayx2 then
wait(1)
print("We meet again....My Arch-nemesis...")
script.Disabled = true
else
print("Don't underestimate my power....")
wait(5)
end

if rage then
wait(1)
print("AHA! I FINALLY HAVE MY HANDS ON YOU. AFTER 50 YEARS I FINALLY FOUND YOU. PREPARE TO BE EXTERMINATED")
script.Disabled = true
else
print("*Ragequit*")
wait(5)
end
end

while true do
findplayer()
wait(5)
end


Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
07 May 2014 12:03 PM
function find()
for _,p in pairs(Workspace:GetChildren()) do
if p:IsA("Model") then
for _,ps in pairs(game.Players:GetPlayers()) do
if p.Name == ps.Name then
return ps
end
end
end
end
end

Here's my siggy... Done.
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
07 May 2014 12:06 PM
local qwerty = script.Parent.Parent.Parent.Parent.Parent.Parent -- I think that is right, not sure.
print (qwerty.Name)
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 12:32 PM
function g()
x = script.Name
return game.Players:FindFirstChild(x)
end
g()

>Script should have the same name as the player's
It will assign x as its name then return the player in Players with a name of x.
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 12:33 PM
Never mind it has the work Players in it...
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
07 May 2014 12:54 PM
function Getplr()
repeat wait() until game:FindFirstChild("PlayerGui",true)
pg = game:FindFirstChild("PlayerGui",true)
return pg.Parent
end

Plr = Getplr()
print(Plr.Name)

print("You have been owned by islandmaker2012")
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 12:58 PM
function x()
for i, v in pairs (game:GetChildren()) do
if v.Name:sub(1,3) == "Pla" then
return v:FindFirstChild(script.Name)
end
end
end
p = x()
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
07 May 2014 12:59 PM
function p()
local s = game.Players:GetChildren()
if s:IsA("Player") then
print (s.name)
end
end

I don't know if I did that correct or not because usually I just use a for loop and use :GetPlayers().
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 12:59 PM
Island your script returns a random player but I think we need a specific player (not sure)
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
07 May 2014 01:00 PM
function x()
repeat wait() until game:FindFirstChild("PlayerGui",true)
pg = game:FindFirstChild("PlayerGui",true)
return pg.Parent
end

a = x()

print"Mine is still best XD,happy now?"
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 01:01 PM
Made it shorter:

function x()
for i,v in next, game:GetChildren() do
if v.Name:sub(1)=="P" then
return v:FindFirstChild(script.Name)
end
end
end
p=x()
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
07 May 2014 01:02 PM
Let me attempt XD

function F()local X=script
for _,v in pairs(game:GetChildren())do
if v.Name:sub(1,4)=="Play"then
local XX=v
end
end
repeat
X=X.Parent
if X.Parent==XX then
return X
end
until X.Parent==XX
end



190 characters!
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
07 May 2014 01:02 PM
function p()
for i,v in pairs(game.Players:GetChildren()) do
if v:IsA("Player") then
print (v.Name)
end
end)
end

Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 01:03 PM
Not going to post a script again, but change game:GetChildren() to game:Children()
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
07 May 2014 01:03 PM
Island, yours has 184 characters.
Mine has 113.
:D
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
07 May 2014 01:05 PM
It does have to be a specific player

Also who the heck thought the player was named Script?
Report Abuse
youssef04 is not online. youssef04
Joined: 22 Jan 2011
Total Posts: 1745
07 May 2014 01:05 PM
function x()
i=game:GetChildren()
for i,v in pairs, (i) do
a=i:findFirstChild(PlayerGui)
p = a.Parent
end
end
p=x()
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
07 May 2014 01:05 PM
Just realized we couldn't use the word 'Players' in our script.
D:
Report Abuse
Kingmouli is not online. Kingmouli
Joined: 28 Sep 2012
Total Posts: 1292
07 May 2014 01:05 PM
Spizer you said Players in your script.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
07 May 2014 01:06 PM
@despi

It contained Player in it. Not counted.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
07 May 2014 01:07 PM
Oh and guys, no deprecated methods please
Report Abuse
DeSpizer27 is not online. DeSpizer27
Joined: 13 Jul 2012
Total Posts: 2679
07 May 2014 01:07 PM
I know.
I said I just realized that in my last post.
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