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: why does this not work

Previous Thread :: Next Thread 
FIRECAKE is not online. FIRECAKE
Joined: 28 Feb 2009
Total Posts: 25167
03 Jul 2014 04:18 PM
game.Players.PlayerAdded:connect(function(playa)
if playa.userId==game.CreatorId then
playa.CharacterAdded:connect(function(char)
script.REF:clone().Parent=playa.PlayerGui;
end
)
end end
)

script.Parent.Touched:connect(function(hit)
if hit.Parent:findFirstChild("Humanoid") then
pname = hit.Parent.Name
script.REF:clone().Parent = game.Players.."pname"..PlayerGui
end
end)

i borrowed the first part from a free model that gives the owner of the place the GUI on entry as you can see, im trying to make another function that will also give you the GUI if you touch a brick that the script is in
Report Abuse
FIRECAKE is not online. FIRECAKE
Joined: 28 Feb 2009
Total Posts: 25167
03 Jul 2014 04:19 PM
error message is: line 13 attempt to concatenate global 'PlayerGui' (a nil value)
Report Abuse
samy22 is not online. samy22
Joined: 28 Sep 2008
Total Posts: 2181
03 Jul 2014 04:21 PM
1. Make sure both functions are in the same script.
2. You made a mistake, change this

script.REF:clone().Parent = game.Players.."pname"..PlayerGui


to this


script.REF:clone().Parent = game.Players:findFirstChild(hit.Parent.Name).PlayerGui
Report Abuse
vlekje513 is not online. vlekje513
Joined: 28 Dec 2010
Total Posts: 9057
03 Jul 2014 04:22 PM
I recommend using waitforchild on the REF

script.REF:clone().Parent = game.Players.."pname"..PlayerGui

>
script.REF:clone().Parent = game.Players:FindFirstChild("pname"):FindFirstChild("PlayerGui")

Might break with clones.
Report Abuse
smiley599 is not online. smiley599
Joined: 23 Jan 2010
Total Posts: 21869
03 Jul 2014 04:22 PM
Also change
script.REF:clone().Parent=playa.PlayerGui;
to

script.REF:clone().Parent=playa:WaitForChild("PlayerGui");
Report Abuse
samy22 is not online. samy22
Joined: 28 Sep 2008
Total Posts: 2181
03 Jul 2014 04:23 PM
pname is already a string variable,

("pname") should be (pname)
Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
03 Jul 2014 04:23 PM
You cannot concatenate an object with a string. Listen to the error message.
Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
03 Jul 2014 04:24 PM
Change the line:
script.REF:clone().Parent = game.Players.."pname"..PlayerGui

TO:
script.REF:clone().Parent = game.Players:FindFirstChild(pname).PlayerGui
Report Abuse
samy22 is not online. samy22
Joined: 28 Sep 2008
Total Posts: 2181
03 Jul 2014 04:24 PM
nvm, just realised even in ", still works.. also waitforchild isn't neccesary i think seen as characteradded is used
Report Abuse
FIRECAKE is not online. FIRECAKE
Joined: 28 Feb 2009
Total Posts: 25167
03 Jul 2014 04:43 PM
thanks i didnt realize i was using a string makes sense now
Report Abuse
goro7 is not online. goro7
Joined: 01 Jul 2009
Total Posts: 735
03 Jul 2014 04:48 PM
You are very welcome. ;D
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