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
|
  |
| Joined: 19 Dec 2008 |
| Total Posts: 200 |
|
| |
|
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
|
  |
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 07 Feb 2012 |
| Total Posts: 3371 |
|
|
| 20 Apr 2013 08:38 AM |
game.Players:playerFromCharacter(game.Players[NextIt.Value])
..? |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 19 Dec 2008 |
| Total Posts: 200 |
|
|
| 20 Apr 2013 08:57 AM |
| Oh and yeah, that code is line 131 :) |
|
|
| Report Abuse |
|
|
|
| 20 Apr 2013 08:59 AM |
| replace the GetPlayerFromCharacter bit with game.Players[NextIt.Name] |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|
| |
|
| |
|
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 |
|
|
| |
|
Jackd44
|
  |
| Joined: 19 Dec 2008 |
| Total Posts: 200 |
|
| |
|
|
| 20 Apr 2013 05:35 PM |
| Are you sure its value is not ""? |
|
|
| Report Abuse |
|
|
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
|
  |
| Joined: 19 Dec 2008 |
| Total Posts: 200 |
|
| |
|
|
| 20 Apr 2013 05:42 PM |
| have you checked spelling? |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| Joined: 19 Dec 2008 |
| Total Posts: 200 |
|
|
| 20 Apr 2013 06:14 PM |
| Have I confused everyone? :P |
|
|
| Report Abuse |
|
|