So I am trying to make the animation play when I equipped the tool and making the animation stop playing when unequipped.
But the problem is when I unequip the animation keeps on playing(btw the animation is set to Action, and I’ve also tried all the others and I got the same result).
When equipped:
When unequipped:
This is the code that’s in the tool:
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local WeaponTool = script.Parent
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(WeaponTool.BodyAttach)
char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
char.UpperTorso.ToolGrip.Part1 = WeaponTool.BodyAttach
char.Humanoid:LoadAnimation(script.Animation):Play()
end)
script.Parent.Unequipped:Connect(function()
game.ReplicatedStorage.DisconnectM6D:FireServer()
char.Humanoid:LoadAnimation(script.Animation):Stop()
end)
As you can see, I stated to stop the animation upon unequipping.
And this is the script that’s in the ServerScriptService
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local M6D = Instance.new("Motor6D", char.UpperTorso)
M6D.Name = "ToolGrip"
end)
end)
game.ReplicatedStorage.ConnectM6D.OnServerEvent:Connect(function(plr,location)
local char = plr.Character
char.UpperTorso.ToolGrip.Part0 = char.UpperTorso
char.UpperTorso.ToolGrip.Part1 = location
end)
game.ReplicatedStorage.DisconnectM6D.OnServerEvent:Connect(function(plr)
plr.Character.UpperTorso.ToolGrip.Part1 = nil
end)
Also this is my view:
The output is saying nothing, please I need help on getting an understanding of what I am doing wrong.