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: A little help.

Previous Thread :: Next Thread 
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:08 AM
I was wondering how do you check for the walkspeed on a local humanoid? I am working on something and I need it to check for walkspeed when they walk over a brick.
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
11 Jul 2013 02:10 AM
Well when you touch the brick you can do findFirstChild("Humanoid") set that to a variable lets say "b" so then

local health = b.WalkSpeed -- B is the humanoid we found earlier.
Report Abuse
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:16 AM
local brick = Workspace.t

function onTouched(part)

part.Parent:FindFirstChild("Humanoid")~= nil then

if local health = b.WalkSpeed = "16" then


end
end

script.Parent.Touched:connect(onTouched)

Something like this? I am learning... Sorry if this is 100% wrong.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Jul 2013 02:18 AM
You would need "==" for conditions. If you're directly checking for the walkspeed, no need for the variable, also, the WalkSpeed is an integer, not a string.

if part.Parent.Humanoid.WalkSpeed == 16 then
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Jul 2013 02:19 AM
double*
Report Abuse
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:38 AM
Okay thank you. Can you guys help me out with one more thing?

Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Jul 2013 02:39 AM
Of course.
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
11 Jul 2013 02:40 AM
If you are just starting this is great!

function onTouched(part) -- Part is what was touched

if part.Parent:FindFirstChild("Humanoid") then -- You don't need that other part. This just checks if it's there.
b = part.Parent.Humanoid.WalkSpeed -- That's the walkspeed. You can set it to a value inside the player or do whatever you want with it!
end
end

script.Parent.Touched:connect(onTouched)
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
11 Jul 2013 02:41 AM
Plus number values are not strings so you don't need the ""
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
11 Jul 2013 02:43 AM
I'm confused, are you asking a question?
Report Abuse
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:43 AM
Say I wanted it to check for walkspeed 16 and walkspeed 20. How would I do this?

function onTouched(part)

part.Parent:FindFirstChild("Humanoid")

if part.Parent.Humanoid.WalkSpeed == 16 then
-- Insert code here --

if part.Parent.Humanoid.WalkSpeed == 20 then
-- Insert code here --

end
end

script.Parent.Touched:connect(onTouched)

This doesn't work. (I added the -- Insert code here -- parts.) How do I fix this?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
11 Jul 2013 02:44 AM
Add an end before the second if statement. You could also just change the second if to an elseif.
Report Abuse
Azarth is not online. Azarth
Joined: 17 Aug 2012
Total Posts: 2760
11 Jul 2013 02:46 AM
local db = true
script.Parent.Touched:connect(function(hit)
if hit and hit.Parent:findFirstChild("Humanoid") and db then
db = false
if hit.Parent.Humanoid.WalkSpeed == 16 then
print("Walkspeed = 16")
elseif hit.Parent.Humanoid.WalkSpeed == 20 then
print("Walkspeed = 20")
end
wait()
db = true
end
end)

Report Abuse
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:48 AM
Thank you everyone.
Report Abuse
cool1bird is not online. cool1bird
Joined: 28 Sep 2009
Total Posts: 1488
11 Jul 2013 02:50 AM
I got my script working. Thank you very much.
Report Abuse
ToboboT is not online. ToboboT
Joined: 25 Jun 2011
Total Posts: 2385
11 Jul 2013 06:55 PM
function onTouched(part)

part.Parent:FindFirstChild("Humanoid")

if part.Parent.Humanoid.WalkSpeed == 16 then
-- Insert code here --

elseif part.Parent.Humanoid.WalkSpeed == 20 then
-- Insert code here --

end
end

script.Parent.Touched:connect(onTouched)
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