|
| 06 Aug 2017 05:25 AM |
I want to get the value of WalkSpeed and JumpPower as I have a script that sets the players WalkSpeed and JumpPower to 0 then waits two seconds then after I want it to set it back to what the players WalkSpeed and JumpPower was before.
I want to do this using a variable before it gets set to 0 that saves the players current WalkSpeed and JumpPower as different players can have different values for those.
|
|
|
| Report Abuse |
|
|
|
| 06 Aug 2017 05:28 AM |
ws = game.Players.LocalPlayer.Character.Humanoid.Walkspeed jp = game.Players.LocalPlayer.Character.Humanoid.JumpPower game.Players.LocalPlayer.Character.Humanoid.Walkspeed = 0 game.Players.LocalPlayer.Character.Humanoid.JumpPower = 0 wait(2) game.Players.LocalPlayer.Character.Humanoid.Walkspeed = ws game.Players.LocalPlayer.Character.Humanoid.JumpPower = jp
|
|
|
| Report Abuse |
|
|
|
| 06 Aug 2017 05:29 AM |
| use localscript to use localplayer or change the path of localplayer to a specific player in workspace |
|
|
| Report Abuse |
|
|
FleetyPix
|
  |
| Joined: 14 Jan 2017 |
| Total Posts: 45 |
|
|
| 06 Aug 2017 05:31 AM |
OR you can do this
Player = "JuliusColeChocolateHater"
WS = game.Players[Player].Humanoid.WalkSpeed JP = game.Players[Player].Humanoid.JumpPower |
|
|
| Report Abuse |
|
|
| |
|
FleetyPix
|
  |
| Joined: 14 Jan 2017 |
| Total Posts: 45 |
|
|
| 06 Aug 2017 05:35 AM |
Whoops! I mean
Player = "JuliusColeChocolateHater"
WS = game.Players[Player].Character.Humanoid.WalkSpeed JP = game.Players[Player].Character.Humanoid.JumpPower |
|
|
| Report Abuse |
|
|
|
| 06 Aug 2017 07:41 AM |
| It works fine but as this script is activated by a touch event I had to get the player. I'm just wondering how I could stop this error: "attempt to index local 'player' (a nil value)". |
|
|
| Report Abuse |
|
|
Kaboom680
|
  |
| Joined: 09 Feb 2009 |
| Total Posts: 384 |
|
|
| 06 Aug 2017 04:41 PM |
why would you need to get the player rofl
local hitUnits = {}
local waitDuration = 2 local cooldown = 2
local hitUnits = {}
local waitDuration = 2 local cooldown = 2
#script.Parent.Touched:--[[im putting this comment here because this gets censored for some reason. remove if needed]]connect(function(hit) local humanoid = hit.Parent and hit.Parent:FindFirstChild("Humanoid") if humanoid then for i, units in pairs(hitUnits) do if units == humanoid.Parent then return end end hitUnits[#hitUnits + 1] = humanoid.Parent local WS, JS = humanoid.WalkSpeed, humanoid.JumpPower humanoid.WalkSpeed, humanoid.JumpPower = 0,0 wait(waitDuration) humanoid.WalkSpeed,humanoid.JumpPower = WS, JS wait(cooldown) for i, units in pairs(hitUnits) do if units == humanoid.Parent then table.remove(hitUnits, i) end end end end)
okay so i just made a script for you because im was bored. waitDuration is how long they're unable to move, cooldown is how long they can touch the object after it stops you and not be stopped again.
basically all of the stuff that seems odd about it is to make sure it doesn't affect a humanoid that it already has affected. |
|
|
| Report Abuse |
|
|