#script doesnt stop after remoteevent triggers???

1 messages · Page 1 of 1 (latest)

tender skiff
#

so uhhh for some reason the script wont stop going after the remoteevent gets triggered

local script

local PlayerL = PlayerS.LocalPlayer

local Claymore = script.Parent
local Sword = Claymore.Handle

local CRE = script.ClickRE

Claymore.Activated:Connect(function()
    local Debounce = false    
    Debounce = true
    
    Sword.Touched:Connect(function(Hit)
        if Hit then
            local HitHumanoidH = Hit.Parent:FindFirstChild("Humanoid")
            
            CRE:FireServer(HitHumanoidH)
        end
    end)
    
    wait(0.5)
    
    Debounce = false
end)```

# script (bugged)

```local Claymore = script.Parent
local Sword = Claymore.Handle

local CRE = Claymore.ClickLS.ClickRE

CRE.OnServerEvent:Connect(function(Player, HitHumanoidH)
    local Debounce = false
    Debounce = true
    
    Sword.Touched:Connect(function()
        if HitHumanoidH then
            if HitHumanoidH then
                print(1)
            end
        end
    end)
    wait(0.5)
    
    Debounce = false
end)```

im trying to make a script for a sword from scratch and, uhh... yeah. this happens
mystic galleon
#

what do you mean?

#

how many times does "1" get printed?

tender skiff
#

oh i forgot to attach the video uhh

#

indirectly found out i needed to use a hitbox since it would be able to touch multiple limbs yet it still prints roughly the same, if not more times

mystic galleon
#

yea because it's touched

#

it fires everytime the sword being touched

#

u did put debounce, in a wrong way

tender skiff
#

yep

#

ahh ok

mystic galleon
#

u didnt create cooldown

tender skiff
#

how would i? not too good at debounces

mystic galleon
#
local debounce = true
while task.wait() do
if debounce then
debounce = not debounce
print ("fired")
task.wait(2)
debounce = not debounce
end
end ```
#

this will print fired every 2 second

#

that's how debounce work

tender skiff
#

huh alright

tender skiff
#

added the debounce so that problems fixed

#

but theres still one problem

mystic galleon
#

?

tender skiff
#

after the first click the script acts like the remoteevent is always fired or something

#

so despite me not clicking its still printing when its near a hitbox

mystic galleon
#

wdym

#

put a vud

#

vid

tender skiff
#

alright

tender skiff
#

the first print was supposed to happen

#

because i clicked

#

but the rest werent because i wasnt clicking

#

but they still happened anyways

#

@mystic galleon

#

apologies for the ping btw

mystic galleon
#

just reduce the time it takes to be set to its original

tender skiff
#

wait huh

#

doesnt it go like debounce false, true, wait, false?

mystic galleon
#

for i = 1,... do
Humanoid:TakeDamage(...)
end

tender skiff
mystic galleon
#

it would give damage multiple times

tender skiff
#

kind of not what i was going for but i appreciate the effort

#

im trying to figure out why the script keeps running seconds after the onserverevent fires

white zenithBOT
#

studio** You are now Level 4! **studio

shut galleon
#

Coroutines

tender skiff
#

heres the new script too

#

what

shut galleon
#

Nah

tender skiff
#

i cant send it??

shut galleon
#

But you could resume it when you need

tender skiff
#

hmm

shut galleon
#

When you click you call it

#

And then when the animations end you can stop it

tender skiff
#

if theres no other way then ill try that

shut galleon
#

Why do you mean by running once ?

tender skiff
#

well

shut galleon
#

Is it like

#

The even running a single time

tender skiff
#

yeah

shut galleon
#

Forever

#

?

tender skiff
#

yeah

shut galleon
#

Then use :Once()

#

Instead of :Connect

tender skiff
#

i have

#

just earlier

#

let me try again tho

#

yep it doesnt work

#

this never happened to me ever while using Part.Touched

shut galleon
#

It fires multiple times ?

tender skiff
#

yep

#

i mean

#

the Part.Touched stays active

#

despite the remoteevent not firing multiple times

#

thats the best i can describe it

#

lemme video again

#

the first one i clicked

#

the rest i wasnt

shut galleon
#

But why are you using a localscript for the sword in the first place ?

tender skiff
#

yes

#

a localscript for the remoteevent

shut galleon
#

Why*

tender skiff
#

for the clicking

shut galleon
#

You don’t need to

tender skiff
#

and the player specific things

#

like things you cant get easily within a normal script

shut galleon
#

You can do .Activated in a server script

shut galleon
tender skiff
#

yeah

shut galleon
#

You can easily get the player using the server script

#

When the tool is activated, it is obviously equipped, right ?

tender skiff
#

yep

shut galleon
#

When the tool is equipped, the tool’s parent is the Character

#

Therefore, when you activate your tool, you can just

local Player = game:GetService("Players"):GetPlayerFromCharacter(script.Parent.Parent)```
tender skiff
#

hm

#

hold on

shut galleon
#

Should work if the script is the child of the tool

tender skiff
#

hm alright lemme just try that real quick

shut galleon
#

K gotta go shower

#

Lmk what happens

#

Ill come back soon

tender skiff
#

alr

shut galleon
#

Yo

#

How’s it been so far ?

tender skiff
#

been taking 5 minutes for studio to boot up now