So, I have been recent, as you might know, if you saw my past posts, been trying to make an OTS gun system, the only problem is that animations ain’t working. But passing to the important part, I have been trying to make the animations load, and eventually even managed to make them work but only idle animation. Now I tried to remake the code as a whole and it’s looking really bad ingame. Gives a ton of errors out of nowhere.
In case you need it, there you are the script.
–[[LOCALS]]–
local Weapon = script.Parent -- Variable for the Tool
local player = game.Players.LocalPlayer -- Gets the Player
repeat wait(1) until player.Character
local char = player.Character -- Gets the Player's character
local mouse = player:GetMouse()
local isEnabled = false
local hum = char:WaitForChild("Humanoid")
local Animator = hum:WaitForChild("Animator")
local HoldAnim = Animator:LoadAnimation(script.Idle_Anim)
local AimAnim = Animator:LoadAnimation(script.Aim_Anim)
--[[FUNCTIONS]]--
Weapon.Equipped:Connect(function() -- To start the animation whenever the Tool Is Equipped
warn("equip")
script.LidUp:Play()
isEnabled = true
if isEnabled == true and not mouse.Button2Down then
mouse.Transparency = 1
print("Hold")
end
end) -- End of the function
Weapon.Unequipped:Connect(function()
warn("unequip")
script.LidDown:Play()
HoldAnim:Stop()
AimAnim:Stop()
wait(0.025)
isEnabled = false
end)
if mouse.Button2Up and not AimAnim then
wait(0.01)
AimAnim:Stop()
wait(0.01)
HoldAnim:Play()
end
if mouse.Button2Down and not HoldAnim then
wait(0.01)
HoldAnim:Stop()
wait(0.01)
AimAnim:Play()
end