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
|
  |
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
| |
|
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 |
|
|
| |
|
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
|
  |
| 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
|
  |
| Joined: 17 Aug 2012 |
| Total Posts: 2760 |
|
|
| 11 Jul 2013 02:43 AM |
| I'm confused, are you asking a question? |
|
|
| Report Abuse |
|
|
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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 28 Sep 2009 |
| Total Posts: 1488 |
|
| |
|
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
|
  |
| 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 |
|
|