|
| 17 Jul 2013 03:25 PM |
I made a script to increase a user's walkspeed to 32, thenwait for 10 seconds to reset the user's walkspeed back to 16.
--------------------------------------------------------------------------------------------------------------------
function onTouched() script.Parent.Parent.Parent.Workspace.Character.Humanoid.WalkSpeed = 32 script.Parent.BrickColor = BrickColor.new("Medium stone grey") script.Parent.Transparency = 0.5 wait(10) script.Parent.Parent.Parent.Workspace.Character.Humanoid.WalkSpeed = 16 script.Parent.BrickColor = BrickColor.new("Neon orange") script.Parent.Transparency = 0 end
script.Parent.Touched:connect(onTouched)
--------------------------------------------------------------------------------------------------------------------
The script did not perform at all after I touched it, and I did not find any error messages in the output when I tested in solo mode. If somebody could tell me how to fix the script, that would help me a lot. In addition to helping fix the script, I'd also like help on where to put a debounce so the script doesn't run too many times. |
|
|
| Report Abuse |
|
|
kinglime
|
  |
| Joined: 27 Jun 2008 |
| Total Posts: 2751 |
|
| |
|
|
| 17 Jul 2013 03:34 PM |
| That's why I am asking for help. If you can't help don't post. |
|
|
| Report Abuse |
|
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 17 Jul 2013 03:45 PM |
script.Parent.Parent.Parent.Workspace.Character.Humanoid.WalkSpeed = 32
loldafuq?
You can't do "Workspace.Character" because the character is named after your player.
If the part that touched the brick has a parent, then a child Humanoid, then it's a player. So;
function onTouched(hit) -- It's important you have hit in there. if not debounce then debounce = true if hit.Parent:FindFirstChild("Humanoid") then hit.Parent.Humanoid.Walkspeed = MYFAVENUMBER --rest of script
end debounce = false end
Love me? Find me on Twitter! @DrWafflerRBLX
|
|
|
| Report Abuse |
|
|
| |
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 17 Jul 2013 03:49 PM |
I consider myself novice.
Love me? Find me on Twitter! @DrWafflerRBLX |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2013 03:55 PM |
debounce = false
function onTouched(part) hum = part.Parent:FindFirstChild("Humanoid") if hum ~= nil and debounce == false then debounce = true hum.WalkSpeed = 32 script.Parent.BrickColor = BrickColor.new("Medium stone grey") script.Parent.Transparency = 0.5 wait(10) hum.WalkSpeed = 16 script.Parent.BrickColor = BrickColor.new("Neon orange") script.Parent.Transparency = 0 debounce = false end
script.Parent.Touched:connect(onTouched) |
|
|
| Report Abuse |
|
|
DrWaffler
|
  |
| Joined: 16 Sep 2011 |
| Total Posts: 4248 |
|
|
| 17 Jul 2013 03:56 PM |
@frost, I really like doing
if not debounce then
because I don't have to pre-define the variable.
Love me? Find me on Twitter! @DrWafflerRBLX |
|
|
| Report Abuse |
|
|
|
| 17 Jul 2013 04:01 PM |
@frost
That doesn't work. :L |
|
|
| Report Abuse |
|
|