Hello.
I’ve got two Animations.
Code:
local RS = game:GetService('ReplicatedStorage')
local Plr = game.Players.LocalPlayer
repeat wait() until Plr.Character:FindFirstChild('Torso')
local Char = Plr.Character
local WeaponTool = script.Parent
local Safety = false
local ReadySt,SafetySt
local UIS = game:GetService('UserInputService')
script.Parent.Equipped:Connect(function()
RS.ConnectM6D:FireServer(WeaponTool.BodyAttach)
Char.Torso.ToolGrip.Part0 = Char.Torso
Char.Torso.ToolGrip.Part1 = WeaponTool.BodyAttach
local Humanoid = WeaponTool.Parent:FindFirstChild('Humanoid')
if Humanoid then
ReadySt = Humanoid:LoadAnimation(WeaponTool.ReadyStance)
SafetySt = Humanoid:LoadAnimation(WeaponTool.SafetyStance)
if not Safety then
SafetySt:Stop()
ReadySt:Play()
elseif Safety then
ReadySt:Stop()
SafetySt:Play()
end
--ReadySt:Play()
UIS.InputBegan:Connect(function(Input, GameProc)
if not GameProc then
if Input.KeyCode == Enum.KeyCode.F then
print('F has been pressed')
if not Safety then
print('Safety On')
Safety = true
ReadySt:Stop()
SafetySt:Play()
elseif Safety then
print('Safety Off')
Safety = false
SafetySt:Stop()
ReadySt:Play()
end
end
end
end)
end
end)
WeaponTool.Unequipped:Connect(function()
RS.DisconnectM6D:FireServer()
ReadySt:Stop()
SafetySt:Stop()
end)
Problem [Gyazo]:
https://gyazo.com/4009dd709ea61078689a415394a84f35
So, when I join the game, all works fine. The Animations switch perfectly when I press F. But when de equip the tool, then re equip it, when I press F, the animations wont run. Yet when I dequip and requip the tool again, when I press F, the animations work perfectly fine.
What is going on?
EDIT: Formatted Code