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 » Scripters
Home Search
 

Re: attempt to index local 'player' (a nil value)

Previous Thread :: Next Thread 
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
07 Jun 2017 11:34 PM
this is a server script, i'm not sure why it's not working. Anyone know?


local blob = script.Parent
local player = game.Players:FindFirstChild(script.User.Value)

player.BlobStats.Color.changed:connect(function(newcolor)
blob.BrickColor = BrickColor.new(newcolor)
end)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
07 Jun 2017 11:37 PM
Is User a StringValue?

Also it's Changed not changed.

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
07 Jun 2017 11:39 PM
ya its a stringvalue
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
07 Jun 2017 11:40 PM
Can you print out the value of User before you initialize player? Just so you can see what it's set to.

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
07 Jun 2017 11:42 PM
I checked, it was player1

Do you know any other ways of find a local player using a server script?
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
07 Jun 2017 11:43 PM
Not possible, local players can only be accessed via local scripts.

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
07 Jun 2017 11:47 PM
I mean all I need to do is find the players name in Players using a server script
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
07 Jun 2017 11:48 PM
Yes that's it

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
07 Jun 2017 11:56 PM
i figured it out, I just needed to add a wait(1)


anyway, can you help with my next issue?

error:
bad argument #1 to 'new' (Color3 expected, got BrickColor)

Color is a BrickColorValue inside a folder called BlobStats

player.BlobStats.Color.Changed:connect(function(newcolor)
blob.BrickColor = BrickColor.new(newcolor)
end)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
07 Jun 2017 11:58 PM
Print out the new color variable. See if it prints out a name or a color3. It should print out a name or something. Tell me what it prints.

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:01 AM
Prints out the color name (Black, Earth green, etc)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:03 AM
And you're sure that the parent of the script is a BasePart? (Part, UnionOperation, MeshPart)?

Try doing this instead, not sure if it will have any effect:

blob.Color = BrickColor.new(newcolor).Color

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:07 AM
It is.


And that had the same outcome
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:13 AM
Oh wait... What class is BlobStats? You might need to rename the "Color" thing something else because Color is a property that takes Color3s. Rename it to Col or something and see if that works

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:21 AM
That didn't work. I got the same error.

But what's weird is that I changed it to:

player.BlobStats.BlobColor.Changed:connect(function(newcolor)
print(newcolor)
blob.BrickColor = Color3.new(newcolor)
end)

And got this error:

bad argument #3 to 'BrickColor' (BrickColor expected, got Color3)

Previous Error:

bad argument #1 to 'new' (Color3 expected, got BrickColor)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:24 AM
Well it technically did work, you just changed it from BrickColor.new(newcolor) to Color3.new(newcolor)

So just change it back to BrickColor and you should be good :^)

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:28 AM
then I still get this error

bad argument #1 to 'new' (Color3 expected, got BrickColor)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:30 AM
Send the full script that gives you that error again

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:32 AM
wait(1)
local blob = script.Parent
local player = game.Players:FindFirstChild(script.User.Value)

player.BlobStats.BlobColor.Changed:connect(function(newcolor)
print(newcolor)
blob.BrickColor = BrickColor.new(newcolor)
end)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:35 AM
- Change game.Players:FindFirstChild to game.Players:WaitForChild
- Add print(blob.ClassName) after you define player

discord.gg/fissygames
Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 12:57 AM
print out "Part"

error:

bad argument #1 to 'new' (Color3 expected, got BrickColor)
Report Abuse
EncodedLua is online. EncodedLua
Joined: 02 May 2012
Total Posts: 1555
08 Jun 2017 12:58 AM
That's really odd... I can't think of anything else that could be wrong here...

discord.gg/fissygames
Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
08 Jun 2017 01:02 AM
Is BlobColor a BrickColor value or a StringValue?


Report Abuse
Surgo is not online. Surgo
Joined: 11 Jan 2011
Total Posts: 2748
08 Jun 2017 01:05 AM
BlobColor is a BrickColorValue
Report Abuse
PhantomVisual is not online. PhantomVisual
Joined: 08 Apr 2011
Total Posts: 2025
08 Jun 2017 01:07 AM
wait(1)
local blob = script.Parent
local player = game.Players:FindFirstChild(script.User.Value)

player.BlobStats.BlobColor.Changed:connect(function(newcolor)
print(newcolor)
blob.BrickColor = player.BlobStats.BlobColor.Value
end)


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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