local WeaponTool = script.Parent
local securityCode = "KSKIEIKA09**^^@90[PJ)@&(@8829){p)@_lk_}K2=*_@&@)&@^%@@&()&@0]"
local securityCode2 = "220K9)(kj&9NHH79*h()9jpoih8t9g8f764e7897H60j)(&t&*8HJ^%4364789loimuno(*&()5*bvdy47D$#%*09jjjjjlkJIUoihingON"
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
local idle = h:LoadAnimation(script:WaitForChild("Idle"))
local equip = h:LoadAnimation(script.Equip)
script.Parent.Equipped:Connect(function()
game.ReplicatedStorage.ConnectM6D:FireServer(securityCode2,WeaponTool.BodyAttach)
char.Torso.ToolGrip.Part0 = char.Torso
char.Torso.ToolGrip.Part1 = WeaponTool.BodyAttach
equip:Play()
wait(0.28)
equip:Stop()
idle:Play()
end)
WeaponTool.Unequipped:Connect(function()
idle:Stop()
game.ReplicatedStorage.DisconnectM6D:FireServer(securityCode)
end)
And I used action, for animation type, all other animations are working, but idle animation wont stop
Note: I don’t wanna give other script, but there’s the part when tool is activated:
script.Parent.Activated:Connect(function()
if script.Parent.Debounce.Value == false then
script.Parent.Debounce.Value = true
local char = script.Parent.Parent
local idle = char.Humanoid:LoadAnimation(script.Parent.EquipToolClient.Idle)
local attack = char.Humanoid:LoadAnimation(script.Parent.EquipToolClient.Attack)
script.Parent.BodyAttach.Slash:Play()
attack:Play()
wait(1)
attack:Stop()
idle:Play()
script.Parent.Debounce.Value = false
end
end)
if its already fixed, I’ll just give you a tip then.
while animationTrack.IsPlaying do -- will always stop the animation, no matter what.
animationTrack:Stop()
end
or
for _, track in ipairs(Humanoid:GetPlayingAnimationTracks()) do
if track.Animation.AnimationId == "the id of the track you want to stop" then
track:Stop()
break
end
end
Thanks for idea, it can shorten code, but i dont really need that, if i was still writing the code, this helped me, but thanks for reply! Also you can test that sword here:
local touchConn
touchConn = part.Touched:Connect(function(touch)
if touch.Parent:FindFirstChild("Humanoid") then
if touch.Parent.Name ~= player.Name then
touch.Parent.Humanoid:TakeDamage(math.random(17,35))
if touchConn ~= nil then touchConn:Disconnect() end
end
end
end)
Yes that should remove the damage delay but if you still have issues with any kind of delay its probably the debounce on tool.Activated, try to avoid using wait() and wait(n).
Oh, I just realized, you should have the disconnect there:
local touchConn
touchConn = part.Touched:Connect(function(touch)
if touch.Parent then -- some if statement
end
touchConn:Disconnect() -- you should disconnect always there because sometimes you won't hit something.
end)
local touchConn
touchConn = script.Parent.BodyAttach.DamagePart.Touched:Connect(function(touch)
if touch.Parent then
local humanoid = touch.Parent:WaitForChild("Humanoid")
if touch.Parent.Name ~= script.Parent.Parent.Name then
touch.Parent.Humanoid:TakeDamage(math.random(17,35))
script.Parent.BodyAttach.Hit:Play()
if humanoid.Health <= 0 then
UntagHumanoid(humanoid)
TagHumanoid(humanoid, game.Players:GetPlayerFromCharacter(script.Parent.Parent.Name))
print(touch.Parent.Name.." was killed by "..script.Parent.Parent.Name.."!")
end
end
end
touchConn:Disconnect()
end)
But the problem is i can damage only 1 time and nothing happens, if i damage again, and ill make debounce for animation, so it wont lag much and deal much damage