so the weapon equip script used to work, but then I changed some stuff around using attributes, now whenever I press e it equips the sword but when I press e again, it unequips the sword then immediately reequips it
local chr = player.Character
local hum = chr:WaitForChild("Humanoid")
local module = require(game:GetService("ReplicatedStorage").Modules.WeaponModule)
local Name = script.KatanaName.Value
local SwordEquip = false
local debounce = false
uis.InputBegan:Connect(function(input, gpe)
if gpe then return end
if input.KeyCode == Enum.KeyCode.E and chr:GetAttribute("HasSword") == true then
if chr:GetAttribute("SwordEquip") == true and debounce == false then
debounce = true
local WeaponUnEquipAnim = game:GetService("ReplicatedFirst").Animations.KatanaUnEquip
local loadUnEquipAnim = hum:LoadAnimation(WeaponUnEquipAnim)
loadUnEquipAnim:Play()
loadUnEquipAnim:GetMarkerReachedSignal("KatanaUnequipEvent"):connect(function()
module.WeaponUnEquip(player,Name)
end)
task.wait(1)
chr:SetAttribute("SwordEquip",false)
debounce = false
end
if chr:GetAttribute("SwordEquip") == false and debounce == false then
debounce = true
print("this work?")
local WeaponEquipAnim = game:GetService("ReplicatedFirst").Animations.KatanaEquip
local loadEquipAnim = hum:LoadAnimation(WeaponEquipAnim)
loadEquipAnim:Play()
loadEquipAnim:GetMarkerReachedSignal("SpawnSwordEvent"):connect(function()
module.WeaponEquip(player,Name)
end)
local WeaponIdleAnim = game:GetService("ReplicatedFirst").Animations.KatanaIdle
local loadIdleAnim = hum:LoadAnimation(WeaponIdleAnim)
loadIdleAnim:Play()
task.wait(1)
chr:SetAttribute("SwordEquip", true)
debounce = false
end
end
end)