generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

RenderStepped

Previous Thread :: Next Thread 
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
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
iJacobness is not online. iJacobness
Joined: 20 Jan 2014
Total Posts: 4944
14 Jul 2016 09:22 PM
there is event:Disconnect but its "Obsolete"


r+://393244197r+://393244224r+://393244262
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:24 PM
hm
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:27 PM
I rlly need help with this :p
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:31 PM
bump :/
Report Abuse
RealityBender is not online. RealityBender
Joined: 05 Mar 2016
Total Posts: 43
14 Jul 2016 09:32 PM
Maybe destroy the script? idk xD
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:36 PM
Its on a main localscript lol I cant destroy it xD
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:48 PM
bump
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:54 PM
bump2
Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
14 Jul 2016 09:58 PM
wait I forgot to replace the KeyDown to KeyUp ;-;
Report Abuse
Siarius is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image