PyracelJoin Date: 2013-07-21 Post Count: 3207 |
the animTrack is a loopable crouch animation. When you press c it plays the animation until c is pressed again or so I thought. I dont know how to fix this! Do you have any idea how I could make this work.
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local animation = game.Players.LocalPlayer.Character:WaitForChild("Crouch")
local animTrack = script.Parent.Parent.Character.Humanoid:LoadAnimation(animation)
local Mouse = game.Players.LocalPlayer:GetMouse()
local Crouching = false
Mouse.KeyDown:connect(function(key)
if key == "c" and Crouching == false then
Crouching = true
repeat wait(1)animTrack:Play() until Crouching == false
end
end)
Mouse.KeyDown:connect(function(key)
if key == "c" and Crouching == true then
Crouching = false
animTrack:Stop()
end
end) |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
Bump |
|
|
I think the problem is that you overwrote the function. Just keep everything in one function.
Mouse.KeyDown:connect(function(key)
if key == "c" and Crouching == false then
Crouching = true
repeat wait(1)animTrack:Play() until Crouching == false
elseif if key == "c" and Crouching == true then
Crouching = false
animTrack:Stop()
end
end) |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
But then it would run the first part, change "Crouching" to true, there fore running the second function. |
|
|
No, it'll completely ignore the second function even if crouching is changed to true. Just try it out. |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
I said that because I have had experience with it doing what I just told you. It didnt work, just as I had suspected. |
|
|
Oh, I found a problem that might be it, I put an if directly after elsif. Try this:
Mouse.KeyDown:connect(function(key)
if key == "c" and Crouching == false then
Crouching = true
repeat wait(1)animTrack:Play() until Crouching == false
elseif key == "c" and Crouching == true then
Crouching = false
animTrack:Stop()
end
end) |
|
llaserxJoin Date: 2011-12-10 Post Count: 53069 |
|
|
|
CasualistJoin Date: 2014-06-26 Post Count: 4443 |
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local animation = character:WaitForChild("Crouch")
local animTrack = character:WaitForChild("Humanoid"):LoadAnimation(animation)
local Mouse = player:GetMouse()
local Crouching = false
Mouse.KeyDown:connect(function(key)
if not key:lower() == "c" then return end
Crouching = not Crouching
if Crouching then
while Crouching do wait(1) animTrack:Play() end
else
animTrack:Stop()
end
end) |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
Ya ehatever, user input service. The methoad I used works and its simple. Deal With It |
|
ExovisJoin Date: 2015-01-08 Post Count: 1027 |
keydown works fine
fire is outdated
heaters exist
why don't you use a heater while camping or something
does not compute |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
Cuz camping is meant to be old fashioned. |
|
ExovisJoin Date: 2015-01-08 Post Count: 1027 |
and scripting is meant to be scripting
doesn't matter how you do it if it works and you enjoy using a certain method
does not compute |
|
|
Use CFrame then you dont have to worry about seamlessly looping animations using the animation editor
~sharpchain1 Leader of Domini Studios |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
Hmmm... I guess I could do that... But how? |
|
InfocusJoin Date: 2011-04-28 Post Count: 8022 |
repeat wait() until game.Players.LocalPlayer.Character ~= nil
local animation = game.Players.LocalPlayer.Character:WaitForChild("Crouch")
local animTrack = script.Parent.Parent.Character.Humanoid:LoadAnimation(animation)
local Mouse = game.Players.LocalPlayer:GetMouse()
local Crouching = false
Mouse.KeyDown:connect(function(key)
if key == "c" and Crouching == true then
Crouching = false
animTrack:Stop()
elseif key == "c" and Crouching == false then
Crouching = true
repeat wait(1)animTrack:Play() until Crouching == false
end
end)
--
And for the cframe anims:
https://forum.roblox.com/Forum/ShowPost.aspx?PostID=158629446 |
|
PyracelJoin Date: 2013-07-21 Post Count: 3207 |
thanks! |
|