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: playerFromString? Need help with something similar.

Previous Thread :: Next Thread 
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 06:24 AM
So basically I'm trying to make it so a player has been chosen and their name is stored inside a variable named "NextIt"(Don't worry, I have set a path, it knows what NextIt is and where it is.) And soon through my script I get this error:Unable to cast value to Object
Script "Workspace.HideAndSeek", Line 130 - global Choose_It

Ok, so I gathered that it was around line 130, so I take a look there.
130-it = game.Players:playerFromCharacter(NextIt.Value)
131-m.Text = it.Name.." has been chosen! Because they bought the V.I.P room bonus!"
Now after lots of testing and messing around I couldn't understand what was going wrong. Does anyone know the answer?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 06:58 AM
*Shame* Bump.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
20 Apr 2013 07:10 AM
'NextIt'

-> You've not told us it's 'ClassName'. Is it an ObjectValue, or..?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 07:23 AM
Ah yes sorry, NextIt is a string value :) It has already been defined earlier in the script.
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
20 Apr 2013 08:06 AM
The ':GetPlayerFromCharacter()' does not 'accept' a string value as an argument within the method. You have to give it a character object.

For example,
local Thing = game.Players:GetPlayerFromCharacter(Workspace.Player1)

Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 08:17 AM
Yeah, that was part of my playing around, I just have no idea how to use something similar to it with strings. :/
Report Abuse
Desperian is not online. Desperian
Joined: 07 Feb 2012
Total Posts: 3371
20 Apr 2013 08:38 AM
game.Players:playerFromCharacter(game.Players[NextIt.Value])

..?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 08:55 AM
It's getting somewhere after using a bit of what you have posted it seemed to get past that line, then it gets on to the next line and crashes, I'm going to try and solve this one too, but help would be great :) Here is the next line:
m.Text = it.Name.." has been chosen! Because they bought the V.I.P room bonus!"
and here is the error:
Workspace.HideAndSeek:131: attempt to index upvalue 'it' (a nil value)

So like I said, I'll have a go at this one aswell(Like the other problems I've attempted) but help would be good. :)
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 08:57 AM
Oh and yeah, that code is line 131 :)
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Apr 2013 08:59 AM
replace the GetPlayerFromCharacter bit with game.Players[NextIt.Name]
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 09:16 AM
Ok, did that now I'm getting
ItNext is not a valid member of Players
Strange...
Report Abuse
cart6157 is not online. cart6157
Joined: 28 Feb 2009
Total Posts: 2194
20 Apr 2013 09:19 AM
if game.Players:FindFirstChild(NextIt.Value) then
print("OMG CART MUST BE A GENIUS")
end
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 09:40 AM
It's a good thing I don't just copy what people post... I read it! Muhahahaha :P
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Apr 2013 10:11 AM
Sorry, I meant value :P
Report Abuse
Shedletsky60 is not online. Shedletsky60
Joined: 22 Jul 2012
Total Posts: 5
20 Apr 2013 10:16 AM
Lol
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:29 PM
Changed to value, now it says "String expected" on the same line of it = game.Players[NextIt.Value]
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Apr 2013 05:32 PM
Is NextIt a StringValue?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:33 PM
Yes.
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Apr 2013 05:35 PM
Are you sure its value is not ""?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:39 PM
Yes, I have a print line which prints the NextIt's name. However my roblox studio has a bug where I can't actually see values myself, put I can print it. That COULD be the cause.
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:39 PM
*but
Report Abuse
Notunknown99 is not online. Notunknown99
Joined: 05 Sep 2008
Total Posts: 25360
20 Apr 2013 05:42 PM
have you checked spelling?
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:52 PM
Ok, so I can show the value is there because this is 2 lines of the output:
Successful!
Now Player1 will be it next game!
And here is the code inside the "String setting" brick:
6-local Buyer = game.Players:playerFromCharacter(hit.Parent)
7-local NextIt = game.Workspace.ItNext
23-Buyer.leaderstats.Points.Value = Buyer.leaderstats.Points.Value - 30
24-NextIt.Value = Buyer.Character.Name
25-print("Successful!")
26-print("Now "..NextIt.Value.." will be it next game!")

So the value exists... But now I'm getting this error:
NextIt.Value is not a valid member of Players
Script "Workspace.HideAndSeek", Line 130 - global Choose_It

So it's at line 130. Here's the script near there:
129-if NextIt.Value ~= nil then
130-it = game.Players["NextIt.Value"]
131-m.Text = it.Name.." has been chosen! Because they bought the V.I.P room bonus!"

I have no idea what's going on. Please help! :/
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 05:54 PM
Oh and aswell. The ["NextIt.Value"] with the speech marks don't matter, it's the same error with and without them.
Report Abuse
Jackd44 is not online. Jackd44
Joined: 19 Dec 2008
Total Posts: 200
20 Apr 2013 06:14 PM
Have I confused everyone? :P
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