Making a script where you can do a quick grenade throw, and it kind of works but the problem is the animations don’t work anymore when I switch to a different tool
Here’s what I mean:
https://gyazo.com/b310de7ff22e214a4ec15643c6645bd0
local RunService = game:GetService("RunService")
local RS = game:GetService("ReplicatedStorage")
local UIS = game:GetService("UserInputService")
local Tool = script.Parent
local Arms = game.Workspace.Camera:WaitForChild("Arms")
local AnimationController = Arms.Animation
local holdDuration = 6 -- seconds to hold for
local uis = game:GetService("UserInputService")
local down, time = false, 0
local FragEquip = AnimationController:LoadAnimation(script.FragEquip)
local FragThrow = AnimationController:LoadAnimation(script.FragThrow)
uis.InputBegan:Connect(function(i,gp)
if gp then return end
if i.KeyCode ~= Enum.KeyCode.G then return end
FragEquip:Play()
print("tap")
down,time = true,os.clock()
task.wait(holdDuration)
if os.clock()-time < holdDuration then return end -- if user let go of key and then held it down again
print("held")
end)
uis.InputEnded:Connect(function(i,gp)
if i.KeyCode ~= Enum.KeyCode.G then return end
down = false
if os.clock()-time > holdDuration then return end
print("throw")
FragThrow:Play()
FragEquip:Stop()
end)
I get no errors from this too, help??