Weird bug with my sword
-
What do you want to achieve? A very modular sword template, which you can set all settings inside of the tool. ( damage, cooldown, throwable and more on later… )
-
What is the issue? The sword doesn’t damage any character when activated.
Here is a video of my problem: ( may not work if that’s the case i am sorry )
- What solutions have you tried so far? Now i tried the roblox’s AI ( roblox assistant ) to get the problem not so fixed ( it just deleted the activation system ) since it doesn’t wanna listen to you
i also tried maybe using the free models but i wanted a more modular ( because i don’t want to rewrite the code for every sword ) sword that i can set the cooldown, damage, if it’s throwable and all the others things you might have in mind.
So in short it’s what i am doing here but worse.
Some extra info ( may be useless but i am not sure )
I may have a older version of roblox ( since i use vinegar’s roblox studio )
Here is a picture of the explorer ( you don’t need to thank for the microwave quality )
So here’s the script, if you find something wrong pleaseeee tell me i want to finally have this finished.
MeleeLogic - ServerSide script
-- depends
local Sword = script.Parent
local DamageSetting = script.Parent.Damage.Value
local ThrowableSetting = script.Parent.Throwable.Value
local Cooldown = script.Parent.Cooldown.Value
-- DO NOT CHANGE
Sword.Enabled = false
local Debounce = false
-- Main Action
local function DamageThings(Hit)
-- check if its a character and check if sword is activated
if Hit.Parent.Humanoid and Debounce then
-- make the player/rig take damage
local Human = Hit.Parent.Humanoid
Human:TakeDamage(DamageSetting)
print("Player took damage.")
end
-- end
end
Sword.Handle.Touched:Connect(function(hit)
-- check if activated and touching part with a humanoid ( IS IN DAMAGE THINGS FUNCTION )
DamageThings(hit)
end)
Sword.Activated:Connect(function()
if not Debounce then
Debounce = true
Sword.Enabled = true
print("DEBOUNCE IS TRUE")
DamageThings()
-- Cooldown
task.wait(Cooldown)
-- disable sword
Sword.Enabled = false
Debounce = false
end
end)