My sword doesn't damage when activated

Weird bug with my sword

  1. 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… )

  2. 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 )

  1. 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 :roll_eyes:

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)
3 Likes

is this what you want?

local Sword = script.Parent
local DamageSetting = script.Parent.Damage.Value
local ThrowableSetting = script.Parent.Throwable.Value
local Cooldown = script.Parent.Cooldown.Value

Sword.Enabled = false
local Debounce = false

local function DamageThings(Hit)
    if Hit.Parent.Humanoid then
        local Human = Hit.Parent.Humanoid
        Human:TakeDamage(DamageSetting)
        print("Player took damage.")
    end
end

Sword.Handle.Touched:Connect(function(hit)
    if Sword.Enabled then
        DamageThings(hit)
    end
end)

Sword.Activated:Connect(function()
    if not Debounce then
        Debounce = true
        Sword.Enabled = true
        print("DEBOUNCE IS TRUE")
        task.wait(Cooldown)
        Sword.Enabled = false
        Debounce = false
    end
end)
3 Likes

I tried but it didn’t work, maybe it has to do something with the tool settings? :thinking: i will check real quick

2 Likes

Sadly i tried changing every property but it didn’t fix the main problem, but thanks for trying anyways.

2 Likes

you can put the tool and all its children inside a rbxm file and send it here, i’ll fix it for you

3 Likes

Here’s the Sword.
Sword.rbxm (5.9 KB)

2 Likes

it couldbe the damage function

2 Likes

No, it couldn’t be since in the video after deleting the check if it’s activated it does damage the characters.

1 Like

wait no is sword.enabled property

1 Like

the sword.enabled being set to false prevents the sword.activated event

2 Likes

And why not set up a connection for the handle touched event within the Activated event

1 Like

Wait i tried it rn and it WORKED!! Thank you so much!

1 Like

No problem its just that you wouldnt be able to activate or deactivate the tool again when you set its property enabled to false.Only if you manually set it yourself by toggling its property

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.