Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 05:49 PM |
localPlayer = game.Players.LocalPlayer localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait() mouse = localPlayer:GetMouse() humanoid = localCharacter:WaitForChild("Humanoid")
My variables, it's in a localscript in startergui.
When my character dies, the whole script breaks which makes it seem like it's the fault of the variables. Is it? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Dec 2014 05:50 PM |
| Right above humanoid, add a wait() :) |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 05:53 PM |
localPlayer = game.Players.LocalPlayer localCharacter = localPlayer.Character or localPlayer.CharacterAdded:wait() mouse = localPlayer:GetMouse() wait() humanoid = localCharacter:WaitForChild("Humanoid")
still breaks D: |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 29 Dec 2014 05:55 PM |
| I don't think it's from those 4 lines but WaitForChild always seemed, well, weird for me. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 05:56 PM |
| The script is like 100 lines, everything works just fine as they should before I die once... |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 05:57 PM |
| oh and it works fine in play solo |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2014 06:04 PM |
| well in that case, i learned the same today is that LocalPlayer does not work off of solo mode, so it all the stuff mentioning LocalPlayer that is breaking it |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 06:06 PM |
| well it shouldnt and it only breaks when i reset so it may be the localCharacter because I use that a lot |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2014 06:06 PM |
| plus, usually when i grab the humanoid i use FindFirstChild, not WaitForChild |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 29 Dec 2014 06:07 PM |
| well here I need WaitForChild and not FindFirstChild |
|
|
| Report Abuse |
|
|
|
| 29 Dec 2014 06:07 PM |
| The vars look like they were declared correctly. You should probably look elsewhere for where it might be breaking (Sometimes the output can be misleading!) |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 29 Dec 2014 06:11 PM |
can you tell us what it says when it breaks, it looks like
error description with disconnected event or
scriptName:error script line that caused it script lines that lead up to it |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Dec 2014 01:01 PM |
| bumperino alabama al dente |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|
|
| 30 Dec 2014 02:55 PM |
repeat wait(1) until game.Players.LocalPlayer local player = game.Players.LocalPlayer local char = player.Character local torso = char:WaitForChild('Torso') |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Dec 2014 03:07 PM |
gg
it worked hooray
I used repeat wait() in my last script but...some guy told me it was no use in startergui localscripts
whatever |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Dec 2014 03:09 PM |
That doesn't make sense, it's probably the wait(1) fixing it. Since the LocalPlayer will exist when that script is run (obviously because PlayerGui is a child of the player).
So just wait(1), no need for the repeat :) |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
|
| 30 Dec 2014 03:13 PM |
Heh yeah, it works then aswell.
It's so weird, like I didn't think of adding any waiting because it's in the playergui and player is already loaded n' all :/ |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 30 Dec 2014 03:14 PM |
| Yeah, this shouldn't be a problem and your original script should have worked fine. I feel as if it's more Roblox's fault than yours. |
|
|
| Report Abuse |
|
|
Fedorakid
|
  |
| Joined: 17 Jul 2010 |
| Total Posts: 7079 |
|
| |
|