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 » Scripters
Home Search
 

Re: Works in Studio only

Previous Thread :: Next Thread 
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
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
TheComputerist is not online. TheComputerist
Joined: 28 Oct 2011
Total Posts: 695
21 Feb 2015 09:15 AM
is it in a localscript?
Report Abuse
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
21 Feb 2015 09:23 AM
yep
I found a error it says

"Attempt to index char a nil val"
Report Abuse
Bebee2 is not online. 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
AhtnamasStudio is not online. AhtnamasStudio
Joined: 15 Jan 2014
Total Posts: 1104
21 Feb 2015 09:32 AM
yeah I did thatnks though man this is why I should not script in the morning
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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 is not online. 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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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 is not online. 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
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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