#Activate events fires, and the the touched part doesn't stop touching

55 messages · Page 1 of 1 (latest)

quasi river
#

can someone help me rq, whenever I press on the sword and the sword touches the part its supposed to fire the event at, it keep firing and dont stop after one m1

Tool.Activated:Connect(function()
    
    if db == false then
        db = true
        wait(.4)
        
            
            hitbox.Touched:Connect(function(hit)
                    print(hit)
                if hit == "Training Log" then
                    print("worked")
                    SwordTool:FireServer()
                    game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Clicks").Value = plr:FindFirstChild("leaderstats").Clicks.Value + 5 -- adding one every time
                else     
                    -- this is for sword image and the CLicks +
                    SwordTool:FireServer() -- make this fire a different event
                    game.Players.LocalPlayer:WaitForChild("leaderstats"):WaitForChild("Clicks").Value = plr:FindFirstChild("leaderstats").Clicks.Value + 1 -- adding one every time
                print("No")

                end
            
            end)```
quasi river
#

@bold hemlock

#

@bold hemlock can u help me pls

#

@woeful zealot

woeful zealot
#

Hm?

silver fjordBOT
#

studio** You are now Level 6! **studio

woeful zealot
#

Try using debounce

#

local debounce = false

#

Then when it activates set it to true

#

So it can't activate again

quasi river
#

i have a db

vale nimbus
#

if hit == "Training Log" then this will never happen because you can't hit a string

woeful zealot
#

Oh ye

quasi river
#

oh yeah ur right

#

I fixed the hit thingy

vale nimbus
#

hitbox.Touched:Connect(function(hit) but I think you can't have a :Connect(function()) inside a function

quasi river
#

u can't >

#

?

#

so how would I detected if the sword was activated ?

#

add a like a sword = false and if it's activated = true

#

then do the script outside of it ?

#

u might have solved my problem

#

lemme go see this

vale nimbus
#

Wait I need to think ab this XD

#

is the hitbox around the sword?

quasi river
#

yh

#

wait when u said u can't have a function inside a function do u mean it work work

#

wont work*

#

or it's not ideal

vale nimbus
woeful zealot
#

Where is the script located at?

vale nimbus
#

because it has to be touched while it's being activated or something

#

you could make a separate function that fires when the hitbox is touched

#

only doing damage

#

and another function that runs when the tool is activated to do the animation

quasi river
#

yeah that's what im doing rn

#

ima see if it works

quasi river
#

I THINK U FIXED IT

vale nimbus
#

(:

quasi river
#

lemme see this again

#

gimmie a sec

woeful zealot
#

Hey bram

vale nimbus
#

?

woeful zealot
#

Are you good with vectors and math?

vale nimbus
#

I mean... for what?

woeful zealot
#

Hm

#

Here can I show you?

vale nimbus
#

uh ok (:

quasi river
#

can you have to functions that listening to the same event ?

vale nimbus
#

ye

quasi river
#

I FREAKING DIDD IT

#

IT WORKS