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 » Scripting Helpers
Home Search
 

Re: Works in build, not in game.

Previous Thread :: Next Thread 
TechWorks is not online. TechWorks
Joined: 04 Jan 2013
Total Posts: 282
06 Jan 2013 02:01 PM
I made a sprinting GUI, and a script to work in all tools. I've tested it in build mode, and it works perfectly, but when I tried testing it in-game with someone else, it broke. Basically, you hit 'c' and sprint for alotted time. All of its nuances work in build mode, but not in game. It is a LocalScript.


Player = script.Parent.Parent.Parent
Character = Player.Character
function Sprint(Key)
print(Character)
if string.lower(Key) == "c" then
if Character:FindFirstChild("Sprinting").Value == 1 then
Character.Sprinting.Value = 0
elseif Character:FindFirstChild("Sprinting").Value == 0 and Character.Sprinting:FindFirstChild("Winded") == nil then
Character.Sprinting.Value = 1
end
end
end

function GetMouseStuff(mouse)
mouse.KeyDown:connect(Sprint)
end

script.Parent.Equipped:connect(GetMouseStuff)
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:04 PM
Player = script.Parent.Parent.Parent
Character = Player.Character
function Sprint(Key)
print(Character)
if string.lower(Key) == "c" then
if Character:FindFirstChild("Sprinting").Value == 1 then
Character.Sprinting.Value = 0
elseif Character:FindFirstChild("Sprinting").Value == 0 and Character.Sprinting:FindFirstChild("Winded") == nil then
Character.Sprinting.Value = 1
end
end
end

function GetMouseStuff(mouse)
mouse.KeyDown:connect(Sprint)
end

script.Parent.Selected:connect(GetMouseStuff)
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:05 PM
Explination:
You're using a HopperBin, not a Tool, so .Equipped should be .Selected.
Ex.
script.Parent.Selected:connect(GetMouseStuff) --correct
script.Parent.Equipped:connect(GetMouseStuff) --incorrect
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
06 Jan 2013 02:05 PM
@hunt Selected is for Hopperbins, if she's using a Tool then she needs Equipped.

To answer your problem, add "wait()" to the top of the script.
So it looks like,

wait()
-- Your code here
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
06 Jan 2013 02:07 PM
even better, after Player = script.Parent.Parent.Parent:

Character = Player.Character or Player.CharacterAdded:wait()

¬ LuaLearners Elite/Writer
Report Abuse
TechWorks is not online. TechWorks
Joined: 04 Jan 2013
Total Posts: 282
06 Jan 2013 02:08 PM
But it's in a tool. Localscripts don't change 'Equipped' to 'Selected', do they?
//First time using a LocalScript
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:08 PM
@1Topcop

She IS using a hopperbin, hence
Player = script.Parent.Parent.Parent
script = script
Parent (1) = hopperbin
Parent (2) = backpack
Parent (3) = player

While using a tool...
Player = script.Parent.Parent.Parent
script = script
Parent (1) = tool
Parent (2) = character
Parent (3) = workspace
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:09 PM
@TechWorks

After you paste that into a localscript, insert it into a HopperBin, and see if it works.
Report Abuse
TechWorks is not online. TechWorks
Joined: 04 Jan 2013
Total Posts: 282
06 Jan 2013 02:10 PM
@1Top

Okay, it's fixed. Thanks.
Btw, a collection of pixels doesn't inherently have a specific gender. A thing to keep in mind.
Report Abuse
1Topcop is not online. 1Topcop
Joined: 09 Jun 2009
Total Posts: 6635
06 Jan 2013 02:11 PM
You're welcome.

-- I win, and (s)he never specified that it was in a tool, or a hopperbin. c:
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:11 PM
......................................__................................................
.............................,-~*`¯lllllll`*~,..........................................
.......................,-~*`lllllllllllllllllllllllllll¯`*-,....................................
..................,-~*llllllllllllllllllllllllllllllllllllllllllll*-,..................................
...............,-*llllllllllllllllllllllllllllllllllllllllllllllllllllll.\.......................... .......
.............;*`lllllllllllllllllllllllllll,-~*~-,llllllllllllllllllll\................................
..............\lllllllllllllllllllllllllll/.........\;;;;llllllllllll,-`~-,......................... ..
...............\lllllllllllllllllllll,-*...........`~-~-,...(.(¯`*,`,..........................
................\llllllllllll,-~*.....................)_-\..*`*;..)..........................
.................\,-*`¯,*`)............,-~*`~................/.....................
..................|/.../.../~,......-~*,-~*`;................/.\..................
................./.../.../.../..,-,..*~,.`*~*................*...\.................
................|.../.../.../.*`...\...........................)....)¯`~,..................
................|./.../..../.......)......,.)`*~-,............/....|..)...`~-,.............
..............././.../...,*`-,.....`-,...*`....,---......\..../...../..|.........¯```*~-,,,,
...............(..........)`*~-,....`*`.,-~*.,-*......|.../..../.../............\........
................*-,.......`*-,...`~,..``.,,,-*..........|.,*...,*...|..............\........
...................*,.........`-,...)-,..............,-*`...,-*....(`-,............\.......
......................f`-,.........`-,/...*-,___,,-~*....,-*......|...`-,..........\........
my brain hurts
Report Abuse
doombringer42 is not online. doombringer42
Joined: 13 Nov 2007
Total Posts: 5445
06 Jan 2013 02:12 PM
a collection of pixels can hold an association to a specific gender which is sufficient to assume that one is of that gender (in modern-day society's context), however.

¬ LuaLearners Elite/Writer
Report Abuse
TechWorks is not online. TechWorks
Joined: 04 Jan 2013
Total Posts: 282
06 Jan 2013 02:12 PM
@hunte
Localscripts retain their position, even if their ancestry changes. At least, that's what I've noticed, so it's probably not everything.
Report Abuse
TechWorks is not online. TechWorks
Joined: 04 Jan 2013
Total Posts: 282
06 Jan 2013 02:13 PM
@doombringer

Maybe so, but said collection of pixels is not, in and of itself, a specific gender. It's gender is what's assigned to it by others' interpretations of what it represents, not by what it is.
Report Abuse
hunte922 is online. hunte922
Joined: 28 May 2008
Total Posts: 6969
06 Jan 2013 02:17 PM
my pixels are gendered
they're all ladies
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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