Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesnt my script work when i press W twice?

Asked by 4 years ago

The point is to make a player run when u press W twice, and stop when u let go of the keys.

local Trcanje = Instance.new('Animation') local Player = game.Players.LocalPlayer local Character = Player.Character local TickJeste = tick() Trcanje.AnimationId = 'rbxassetid://4766569612' PlayTrcanje = Character.Humanoid:LoadAnimation(Trcanje)

game:GetService("UserInputService").InputBegan:connect(function(input,gameprocesed) if input.KeyCode == Enum.KeyCode.Z then for i = 1,16 do local TickDa = tick() local TimePassed = TickDa - TickJeste wait(0.3) if TimePassed <= 1 then wait() game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed + 1.5 PlayTrcanje:Play() end end end end)

game:GetService("UserInputService").InputEnded:connect(function(input,gameprocesed) if input.KeyCode == Enum.KeyCode.Z then for i = 1,16 do local TimePassed = TickJeste wait(0.3) if TimePassed <= 1 then wait() game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed - 1.5 PlayTrcanje:Stop() end end end end)

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:connect(function() game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16 script.Disabled = true end)

0
Could you surround your code with the script lines? you click on a button and it’ll generate two lines of “~”, just put your code in between those please. joshmatt2244 28 — 4y
0
Im sorry im new to the site i did it in my Answer below,thanks btw. TheAkiSa 7 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
local Trcanje = Instance.new('Animation') 
local Player = game.Players.LocalPlayer
local Character = Player.Character
local TickJeste = tick()
 Trcanje.AnimationId = 'rbxassetid://4766569612'
 PlayTrcanje = Character.Humanoid:LoadAnimation(Trcanje)

game:GetService("UserInputService").InputBegan:connect(function(input,gameprocesed)
 if input.KeyCode == Enum.KeyCode.Z then
  for i = 1,16 do
local TickDa = tick()
local TimePassed = TickDa - TickJeste
if TimePassed <= 1 then
  wait()
   game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed + 1.5
    PlayTrcanje:Play()
   end
  end
 end
end)


game:GetService("UserInputService").InputEnded:connect(function(input,gameprocesed)
 if input.KeyCode == Enum.KeyCode.Z then
  for i = 1,16 do
    local TimePassed = TickJeste
    if TimePassed <= 1 then
  wait()
   game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed = game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed - 1.5
    PlayTrcanje:Stop()
   end
  end
 end
end)

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Died:connect(function()
 game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
 script.Disabled = true
end)
0
Z or W? User#17685 0 — 4y
Ad

Answer this question