I’ve made a weapon that has custom animations using Motor6D, so that way the handle isn’t connected to the Right Arm and can be moved freely without moving the Right Arm. The issue is that the script used to make the idle animation play (Local-script, inside of a tool) will suddenly stop after resetting and equipping the weapon again. This also somehow breaks the script as it cannot fire the RemoteEvent (The event is used to play the attack animation and can deal damage towards victims).
--//Tool\\--
local FireExtinguisher = script.Parent
--//Player\\--
local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
--//Services\\--
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//Connections\\--
local Debounce = false
FireExtinguisher.Activated:Connect(function()
if not Debounce and Char.Humanoid.PlatformStand == false then
Debounce = true
FireExtinguisher.AttackEvent:FireServer()
task.wait(5)
Debounce = false
end
end)
FireExtinguisher.Equipped:Connect(function()
ReplicatedStorage.ConnectM6D:FireServer(FireExtinguisher.BodyAttach)
Char.Torso.ToolGrip.Part0 = Char.Torso
Char.Torso.ToolGrip.Part1 = FireExtinguisher.BodyAttach
local IdleAnim = FireExtinguisher.Parent.Humanoid:LoadAnimation(FireExtinguisher.Idle)
IdleAnim:Play()
FireExtinguisher.Unequipped:Connect(function()
ReplicatedStorage.DisconnectM6D:FireServer(FireExtinguisher.BodyAttach)
IdleAnim:Stop()
end)
end)
--Ullapool Caber, We gotta throw the thingy yeah!
I’m experiencing the exact same issue, have you yet to found a solution or are you still undergoing with trying to fix this. ( Been working for nearly an hour and I’m, trying to fix this issue. )
Just optimized your script abit, it now WILL reset the charcter, some additional changes would to also make it also set the humanoid instead of checking everytime when activated, or focefully unequip the tool if something is not found.
local FireExtinguisher = script.Parent
-- Note that players may be able to take your tools.
local Player = nil
local Char = nil
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Debounce = false
local IdleAnim -- store to stop it later
FireExtinguisher.Activated:Connect(function()
if not Debounce and Char and Char:FindFirstChild("Humanoid") and not Char.Humanoid.PlatformStand then
Debounce = true
FireExtinguisher.AttackEvent:FireServer()
task.wait(5)
Debounce = false
end
end)
FireExtinguisher.Equipped:Connect(function()
-- Directly start initializing.
Player = PlayerService:GetPlayerFromCharacter(FireExtinguisher.Parent)
if not Player then return end
Char = Player.Character
if not (Char and Char:FindFirstChild("Torso") and FireExtinguisher:FindFirstChild("BodyAttach")) then return end
ReplicatedStorage.ConnectM6D:FireServer(FireExtinguisher.BodyAttach)
Char.Torso.ToolGrip.Part0 = Char.Torso
Char.Torso.ToolGrip.Part1 = FireExtinguisher.BodyAttach
local Humanoid = Char:FindFirstChild("Humanoid")
if Humanoid then
local Animator = Humanoid:FindFirstChildOfClass("Animator") or Instance.new("Animator", Humanoid)
IdleAnim = Animator:LoadAnimation(FireExtinguisher.Idle)
IdleAnim:Play()
end
local unequippedConn
unequippedConn = FireExtinguisher.Unequipped:Connect(function()
ReplicatedStorage.DisconnectM6D:FireServer(FireExtinguisher.BodyAttach)
if IdleAnim then
IdleAnim:Stop()
IdleAnim = nil
end
if unequippedConn then
unequippedConn:Disconnect()
end
end)
end)