Leg0brick
|
  |
| Joined: 24 Jul 2012 |
| Total Posts: 651 |
|
|
| 11 Oct 2014 12:15 AM |
Hello, I'm working on script that when a player joins, it creates a new BoolValue under player, then changes the name of it. The script makes the value but it wont change the name of it. The script and the error in the output is below.
Script:
game.Players.PlayerAdded:connect(function(newPlayer) local b = Instance.new("BoolValue") wait(1) b.Parent = newPlayer newPlayer.Value.Name = Sweg end)
Output:
22:09:18.312 - String expected 22:09:18.312 - Script 'Workspace.MainStuffs', Line 5 22:09:18.312 - Stack End |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 11 Oct 2014 12:18 AM |
Its because your bool is still named 'Value' so it looks for a property in newPlayer called Value
And also you says Sweg and should have said "Sweg"
game.Players.PlayerAdded:connect(function(player) local bool = Instance.new("BoolValue") bool.Parent = player bool.Name = "Sweg" end)
You could also do this
game.Players.PlayerAdded:connect(function(player) local bool = Instance.new("BoolValue", player) bool.Name = "Sweg" end) |
|
|
| Report Abuse |
|
|
eLunate
|
  |
| Joined: 29 Jul 2014 |
| Total Posts: 13268 |
|
|
| 11 Oct 2014 04:19 AM |
| If you're using waitforchild in another script, waiting for that to exist, it's a good idea to rename it before parenting it to avoid issues |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 11 Oct 2014 12:46 PM |
@eLunate You just solved every problem I've ever had with WaitForChild |
|
|
| Report Abuse |
|
|