|
| 21 Feb 2015 09:14 AM |
local plr = game.Players.LocalPlayer local char = plr.Character while true do wait(.1) if plr.Busy.Value == true then char.Humanoid.WalkSpeed = 0 end if plr.Busy.Value == false then char.Humanoid.WalkSpeed = 16 end end
i am lost O_O |
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Feb 2015 09:23 AM |
yep I found a error it says
"Attempt to index char a nil val" |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 21 Feb 2015 09:28 AM |
repeat wait() until game.Players.LocalPlayer
local plr = game.Players.LocalPlayer local char = plr.Character or plr.CharacterAdded:wait() while true do wait(.1) if plr.Busy.Value == true then char.Humanoid.WalkSpeed = 0 end if plr.Busy.Value == false then char.Humanoid.WalkSpeed = 16 end end |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 09:32 AM |
| yeah I did thatnks though man this is why I should not script in the morning |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 09:33 AM |
"repeat wait() until game.Players.LocalPlayer"
This is pointless because the local script is already a child of the player and if there is no player there is no script
do this:
local character=player:CharacterAdded:wait() -- This doesnt let the rest of the script run until the player joins, and makes you get the character object |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 21 Feb 2015 09:34 AM |
| That line is perhaps the most important line (repeat wait() until game.Players.LocalPlayer) because in some instances, the LocalScript runs before the LocalPlayer exists. This is especially true with those who has poor connection to enter a game or terrible client-sided lag. |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 09:36 AM |
That makes no sense and I've been told by people smarter than me that you don't need it. If the localscript is a child of the player, it cannot be created before the player, and thus cannot be run |
|
|
| Report Abuse |
|
|
Bebee2
|
  |
| Joined: 17 May 2009 |
| Total Posts: 3985 |
|
|
| 21 Feb 2015 09:39 AM |
| It doesn't explain why sometimes when I join my testing server with my ridiculously bad internet, it sometimes give an "Attempt to index a nil variable 'p'" (p being the LocalPlayer). |
|
|
| Report Abuse |
|
|
|
| 21 Feb 2015 09:41 AM |
| Well I don't know what to say then, it works fine for me and I haven't been using it. If you think you need tot hen sure use it. |
|
|
| Report Abuse |
|
|