|
| 14 Jul 2016 09:20 PM |
I am having trouble I guess "Stopping" the service. Its my first time using RenderStepped and I used a keydown function to run it but then how do I stop it when I keyup?
Heres my code. I am working on a gun engine and this is the running animation and the --keyup part will not work because Im guessing the service or something is running. Again its my first time using this.
function run1(key) if key == "0" then running =true game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 local target = CFrame.new(-0.55, -0, -1) * CFrame.Angles(math.rad(-90), math.rad(-50), 0) local speed = 0.1 wait(0.1) game:GetService("RunService").RenderStepped:connect(function() weld3.C1 = weld3.C1:lerp(target,speed) end) end end
game.Players.LocalPlayer:GetMouse().KeyDown:connect(run1)
--left arm function run2(key) if key == "0" then running =true game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 local target = CFrame.new(0.2, 1, -1.3) * CFrame.Angles(math.rad(-90), math.rad(-30), 0) local speed = 0.1 wait(0.1) game:GetService("RunService").RenderStepped:connect(function() weld2.C1 = weld2.C1:lerp(target,speed) end) end end
game.Players.LocalPlayer:GetMouse().KeyDown:connect(run2)
--keyup --right arm function run3(key) if key == "0" then running =true game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 14 local target = CFrame.new(-0.55, -0.25, -1) * CFrame.Angles(math.rad(-90), 0, 0) local speed = 0.1 wait(0.1) game:GetService("RunService").RenderStepped:connect(function() weld3.C1 = weld3.C1:lerp(target,speed) end) end end
game.Players.LocalPlayer:GetMouse().KeyDown:connect(run3)
--left arm function run4(key) if key == "0" then running =true game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 14 local target = CFrame.new(0.1, 1.7, -1.3) * CFrame.Angles(math.rad(-89), math.rad(20), 0) local speed = 0.1 wait(0.1) game:GetService("RunService").RenderStepped:connect(function() weld2.C1 = weld2.C1:lerp(target,speed) end) end end
game.Players.LocalPlayer:GetMouse().KeyDown:connect(run4) |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 09:22 PM |
there is event:Disconnect but its "Obsolete"
r+://393244197r+://393244224r+://393244262 |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jul 2016 09:27 PM |
| I rlly need help with this :p |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jul 2016 09:32 PM |
| Maybe destroy the script? idk xD |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 09:36 PM |
| Its on a main localscript lol I cant destroy it xD |
|
|
| Report Abuse |
|
|
| |
|
| |
|
|
| 14 Jul 2016 09:58 PM |
| wait I forgot to replace the KeyDown to KeyUp ;-; |
|
|
| Report Abuse |
|
|
Siarius
|
  |
| Joined: 01 Apr 2012 |
| Total Posts: 197 |
|
|
| 14 Jul 2016 10:06 PM |
try something like this.
local keyDown = falsw local holdTime = tick() local db = false
--[[assuming everything below is defined alrdy]]--
mouse.KeyDown:connect(function(key)
if key == "0" and db then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 local target = CFrame.new(-0.55, -0, -1) * CFrame.Angles(math.rad(-90), math.rad(-50), 0) local speed = 0.1 wait(0.1)
keyDown = true db = true
while keyDown and (tick() - holdTime) < 30 do
weld3.C1 = weld3.C1:lerp(target,speed)
end
end
--[[u can figure out how to apply the rest urself]]-- |
|
|
| Report Abuse |
|
|
Siarius
|
  |
| Joined: 01 Apr 2012 |
| Total Posts: 197 |
|
|
| 14 Jul 2016 10:09 PM |
forgot some code
local keyDown = falsw local holdTime = tick() local db = false
--[[assuming everything below is defined alrdy]]--
mouse.KeyDown:connect(function(key)
if key == "0" and db then
game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 25 local target = CFrame.new(-0.55, -0, -1) * CFrame.Angles(math.rad(-90), math.rad(-50), 0) local speed = 0.1 wait(0.1)
keyDown = true db = true
while keyDown and (tick() - holdTime) < 30 do
weld3.C1 = weld3.C1:lerp(target,speed)
mouse.KeyUp:connect(function(okey)
keyDown = false db = false
end)
wait(.05)
end
end)
--[[u can figure out how to apply the rest urself]]--
|
|
|
| Report Abuse |
|
|