You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want the tool to stop firing the equipped event when activated
- What is the issue? Include screenshots / videos if possible!
local char = script.Parent
local hum = char:WaitForChild("Humanoid")
local head = char:WaitForChild("Head")
local equipped = false
local attacking = false
char.ChildAdded:Connect(function(thing)
for i,v in pairs(char:GetChildren()) do
if v:IsA("Tool") then
if v.Name == "test" then
v.Activated:Connect(function()
wait(0.1)
local plr = game:GetService("Players"):GetPlayerFromCharacter(char)
local idle = char.Humanoid:LoadAnimation(script.Animations.Idle)
local RaycastHitbox = require(game.ServerScriptService.RaycastHitboxV4)
local Hitbox = RaycastHitbox.new(v.Weapon)
local equip = char.Humanoid:LoadAnimation(script.Animations.equip)
local attack1 = char.Humanoid:LoadAnimation(script.Animations.Attack1)
local Params = RaycastParams.new()
Params.FilterDescendantsInstances = {char} --- remember to define our character!
Params.FilterType = Enum.RaycastFilterType.Blacklist
Hitbox.RaycastParams = Params
Hitbox.OnHit:Connect(function(hit, humanoid)
local damage = math.random(35,40)
if humanoid then
if hit.Parent ~= char then
thing.Weapon:WaitForChild("Hit"):Play()
humanoid:TakeDamage(damage)
hit.Parent.keffect.effect.Value = "mortis"
end
end
end)
v.Equipped:Connect(function()
idle:Play()
equip:Play()
v.Weapon:WaitForChild("equip"):Play()
equipped = true
print("equipped")
end)
v.Unequipped:Connect(function()
idle:Stop()
equipped = false
print("unequipped")
end)
v.Activated:Connect(function()
if not attacking and equipped then
attack1:Play()
print("attacked")
attacking = true
wait(0.34)
Hitbox:HitStart()
thing.Weapon:WaitForChild("Swing"):Play()
wait(0.46)
Hitbox:HitStop()
attacking = false
print("canattack")
end
end)
end)
end
end
end
end)
The script is located in the character controlling the tool