So I have a keyup event which I use to put someones arm down. But for some reason, this keeps randomly triggering for no reason. Sometimes it works, other times it triggers randomly.
mouse.KeyUp:connect(function(key)
if key:lower() == "q" then
if fire then
repeat wait() until ready == true
changeWeight(fire, 0, .3)
ready = false
end
end
end)
I have defined all variables.
local function changeWeight(animationTrack, weight, fadeTime)
animationTrack:AdjustWeight(weight, fadeTime)
local startTime = tick()
while math.abs(animationTrack.WeightCurrent - weight) > 0.001 do
wait()
end
animationTrack:Stop()
end
You should be aware that KeyUp is actually deprecated and shouldn’t be used anymore.
Instead, you should utilise UserInputService where you will be able to detect an input from the user from using InputBegan. Likewise, if you want to detect when a user input ends, you can use InputEnded.