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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Is there a "OnWalking" function?

Previous Thread :: Next Thread 
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
22 Oct 2012 07:14 AM
I'm trying to edit this gun to have it's tool GripPos move up and down when you walk. Does anyone know if such a function exists, if so what would it look like?
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
22 Oct 2012 07:28 AM
script.Parent.Humanoid.Running:connect(function(speed)
if speed > 0 then print("Yes.") end
end)

http://www.roblox.com/CeaselessSouls-Admin-Commands-Gui-based-item?id=92856199 -- Take one and enjoy! Read the description, has a lot of information.
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
24 Oct 2012 01:51 AM
Thank you!
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
24 Oct 2012 02:05 AM
Wait, it doesn't work because the script can't find the player ( In backpack )
So if I did script.Parent.Parent it would find a player.. But the wrong one. I'd have to go all the way to workspace and make it find the children, but I'm not sure how to do that. And I don't think it would work.
Report Abuse
Monkey727 is not online. Monkey727
Joined: 12 Jan 2009
Total Posts: 969
24 Oct 2012 02:22 AM
Player = script.Parent.Parent
Character = Player.Character

?
Report Abuse
Rico2572 is not online. Rico2572
Joined: 18 Sep 2011
Total Posts: 482
24 Oct 2012 04:39 AM
Nope, ontouch function
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
24 Oct 2012 05:01 AM
^ lolwut
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
24 Oct 2012 05:51 AM
Well, if you are using a localscript in the backpack, just change it around like this:


local player = game.Players.LocalPlayer
while (not player.Character and not player.Character:FindFirstChild("Humanoid")) do wait() end

player.Character.Humanoid.Running:connect(function(speed)
if speed ​> 0 then print("Yes.") end
end)
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
24 Oct 2012 07:06 AM
Normally you'd want to loop it,


local player = game.Players.LocalPlayer
while (not player.Character and not player.Character:FindFirstChild("Humanoid")) do wait() end

player.Character.Humanoid.Running:connect(function(speed)
if while speed ​> 0 do
print("running")
wait()
end
end)
Report Abuse
crazyman32 is not online. crazyman32
Joined: 13 Apr 2008
Total Posts: 18027
24 Oct 2012 02:28 PM
@Nate - 'if while'

?
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
24 Oct 2012 04:21 PM
^lol'd
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
24 Oct 2012 05:39 PM
Percicely.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
24 Oct 2012 05:45 PM
"Percicely"

...

-sips tea-
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
24 Oct 2012 05:47 PM
You know those moments... when you just do something without thinking? But obviously meant precisely.
Report Abuse
xXTheRobotXx is not online. xXTheRobotXx
Joined: 05 May 2012
Total Posts: 13343
24 Oct 2012 05:52 PM
yeah, i see what you mean

-sips tea-
Report Abuse
Razghul is not online. Razghul
Joined: 25 Aug 2012
Total Posts: 3626
24 Oct 2012 05:57 PM
yoyopotatoe,

>H&K Leader doesn't know this.

> I do.

>mindeffed
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
24 Oct 2012 06:02 PM
hehe, what if he dies? It will error and break. Try this:

player = game.Players.LocalPlayer
function waitForChar ()
repeat wait() until player.Character
return player.Character
end
while true do
local char = waitForChar()
print(char.Name .. " Is Alive and Well! Or so I Beleave...")
end
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
24 Oct 2012 06:10 PM
Are these functions meant for Local Scripts, or regular? It doesn't seem to be working.

Output on both versions:
16:09:51 - Players.Player1.Backpack.AKS-74u.LocalScript:9: unexpected symbol near 'while'
Report Abuse
ArbiterOfDeath is not online. ArbiterOfDeath
Joined: 20 Jun 2011
Total Posts: 1458
24 Oct 2012 06:14 PM
Thats what we where LOL'ing about. Mine shouldent be doing that, my script does not have a while on line 9. Also, it should be in local scripts. Please post what my script is doing.
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
24 Oct 2012 06:46 PM
It's all in the same Local script.
Report Abuse
SockPuppetCow is not online. SockPuppetCow
Joined: 14 Sep 2012
Total Posts: 121
24 Oct 2012 07:05 PM
You could probably put this into the tool:

person = script.Parent.Parent.Parent
human = person.Humanoid
if human.WalkSpeed > 0 then
INSERT REST OF SCRIPT STUFF HERE
end

Now let me tell you what that script is supposed to do.
Line 1: Assign variable "person" to the script's 'great grandparent' which in this case is the character.
Line 2: Assign variable "human" to person's Humanoid.
Line 3: If the person's walkspeed is above 0, then...
Line 4+: This is where you put the script to make the gun move up and down.
Line 5: end the if statement.
I'm not sure if this will work, I'm just going by what I 'think' I know. Hope it helps though.
Report Abuse
nate890 is not online. nate890
Joined: 22 Nov 2008
Total Posts: 21686
24 Oct 2012 10:04 PM
Remove the "if" beside the "while".
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
25 Oct 2012 05:25 PM
I took out if and the question mark and this happened >

15:24:19 - Character is not a valid member of Backpack
Report Abuse
vat21s is not online. vat21s
Joined: 07 Jun 2010
Total Posts: 2508
25 Oct 2012 06:25 PM
Add 1 more .Parent
Report Abuse
FSSBuilder is not online. FSSBuilder
Joined: 01 Apr 2010
Total Posts: 260
25 Oct 2012 08:46 PM
It works but it spams the output, lol. I'm going to test it with some other stuff
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