KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 06:15 PM |
When you touch this button, your walkspeed becomes 10. I'm wanting it to only be 10 while you're stepping on the button, then go back to normal. Have tried more than a couple ways to do it, none have worked. Help?
function onHumanoid(part) local humanoid = part.Parent:FindFirstChild("Humanoid") if (humanoid ~= nil) then humanoid.WalkSpeed = 10 end end
script.Parent.Touched:connect(onHumanoid) |
|
|
| Report Abuse |
|
|
Soquick
|
  |
| Joined: 01 Nov 2012 |
| Total Posts: 1497 |
|
|
| 21 Sep 2013 06:18 PM |
script.Parent.TouchEnded:connect(function(pt) pcall(function() pt.Parent.Humanoid.WalkSpeed = 16 end) end) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 06:28 PM |
Thanks.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 06:32 PM |
Er, scratch that, your walkspeed doesn't return to normal after you step off of it. I'll be working on it to see if I can find a solution, but I doubt I'll be able to.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2013 06:53 PM |
script.Parent.TouchEnded:connect(function(pt) pcall(function() pt.Parent.Humanoid.WalkSpeed = 16 else pt.Parent.Humanoid.Walkspeed = 8 end) end)
Just alter the eight to desired.
(I don't know if this works, pcall hates me.) |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2013 07:24 PM |
Why are you guys using pcall? No reason to wrap it in such a way when you can easily check if it's a player
script.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then player.Character.Humanoid.WalkSpeed = 10 end end)
script.Parent.TouchEnded:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then player.Character.Humanoid.WalkSpeed = 16 end end) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 07:28 PM |
Mem, I can't use yours, because people in the game will have multiple walkspeeds, not all 16. I'll test out the other one when I can, it looks right.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 07:34 PM |
Er, Crazy, can't use yours either, for the same reason.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
| |
|
Soquick
|
  |
| Joined: 01 Nov 2012 |
| Total Posts: 1497 |
|
|
| 21 Sep 2013 09:04 PM |
cw = 16 script.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then cw = (player.Character.Humanoid.WalkSpeed) player.Character.Humanoid.WalkSpeed = 10 end end) script.Parent.TouchEnded:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then player.Character.Humanoid.WalkSpeed = cw end end) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 09:06 PM |
Erm, Soquick, cannot use that either, due to the same reason as the two above. People playing the game might have 14 walkspeed, might have 16, might have 18 or 20. It could be anything. It just needs to go back to normal after they're off the piece.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
Soquick
|
  |
| Joined: 01 Nov 2012 |
| Total Posts: 1497 |
|
| |
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 09:09 PM |
Why would cw initially = 16?
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
Soquick
|
  |
| Joined: 01 Nov 2012 |
| Total Posts: 1497 |
|
|
| 21 Sep 2013 09:10 PM |
--Just in case 2 people on brick at once-- script.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then ol = Instance.new("IntValue", player.Character.Parent) ol.Name = "OldSpeed" ol.Value = (player.Character.Humanoid.WalkSpeed) player.Character.Humanoid.WalkSpeed = 10 end end) script.Parent.TouchEnded:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then player.Character.Humanoid.WalkSpeed = player.Character.OldSpeed.Value player.Character.OldSpeed:Destroy() end end) |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 09:13 PM |
And So, neither one is working. THey change the speed, but don't change it back.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
Soquick
|
  |
| Joined: 01 Nov 2012 |
| Total Posts: 1497 |
|
|
| 21 Sep 2013 09:15 PM |
script.Parent.Touched:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then ol = Instance.new("IntValue", player.Character.Parent) ol.Name = "OldSpeed" ol.Value = (player.Character.Humanoid.WalkSpeed) player.Character.Humanoid.WalkSpeed = 10 end end) script.Parent.TouchEnded:connect(function(part) local player = game.Players:GetPlayerFromCharacter(part.Parent) if (player) then player.Character.Humanoid.WalkSpeed = player.Character:FindFirstChild("OldSpeed", true).Value player.Character:FindFirstChild("OldSpeed", true):Destroy() end end) |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 21 Sep 2013 09:15 PM |
Hmm..
script.Parent.Touched:connect(OnTouched)
function OnTouched (part) if part.Parent:findFirstChild("Humanoid")~=nil then local speed=part.Parent.Humanoid.WalkSpeed part.Parent.Humanoid.WalkSpeed=10 end script.Parent.TouchEnded:connect(function(peice) if peice.Parent==part.Parent then peice.Parent.Humanoid.WalkSpeed=speed end end) end |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 21 Sep 2013 09:17 PM |
| Soquick's seems much better than mine, though mine still would work... |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 10:32 PM |
Soquick, yours will change the walkspeed to 10, but not bck.
And Trav, yours didn't work at all.
-pls stahp am cryin |
|
|
| Report Abuse |
|
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
| |
|
travddm
|
  |
| Joined: 29 Mar 2012 |
| Total Posts: 926 |
|
|
| 21 Sep 2013 10:34 PM |
| I must have something wrong.. Never used TouchEnded before, care to spew the output? |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 21 Sep 2013 10:36 PM |
20:36:38.826 - attempt to call a nil value 20:36:38.834 - Disconnected event because of exception |
|
|
| Report Abuse |
|
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
| |
|
KodakKid3
|
  |
| Joined: 25 Dec 2008 |
| Total Posts: 2860 |
|
|
| 22 Sep 2013 11:39 AM |
Does anyone know why the above don't work?
-pls stahp am cryin |
|
|
| Report Abuse |
|
|