#Basic scripting help (with wait)

159 messages · Page 1 of 1 (latest)

queen escarp
#
local Part = script.Parent

Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
hit.Parent.Health = hit.Parent.Health - 10
wait(1)
end
end)
#

I think

#

Wait no

#

You need denounce

#

Sory

#

Debounce

#

Add a 1 sec debounce

toxic basin
#

How do I do that?

prisma snow
#

With debounce.

https://create.roblox.com/docs/scripting/scripts/debounce

local Part = script.Parent
local db = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
    if debounce == false then
    debounce = true
      hit.Parent.Health = hit.Parent.Health -= 10
      wait(1)
      debounce = false
    end
end)

Learn with documentation and resources for all creators.

toxic basin
#

What even is a debounce?

prisma snow
#

Debounce is just an cooldown.

#

I don't really know how to explain it, that it is just an cooldown.

toxic basin
#

Oh ok

queen escarp
#

Yeah

toxic basin
#

Could you explain that code a little more so I can do it in future without just copying

queen escarp
#

A cool-down

#

So it pauses between each hit

#

So basically

#

It’s a Boolean variable (true or false)

prisma snow
#

you may just read it in the documetation.

toxic basin
#

Oh ok

queen escarp
#

And it helps pause the hit damage

#

Or just read what he sent

toxic basin
#

Well it isn't doing any dmg now

prisma snow
#

What are the errors?

#

I may do a mistake since im literally coding on discord.

#

ah i forgot smth.

toxic basin
prisma snow
#

lemme fix mistakes.

toxic basin
#

k

queen escarp
#

It says you are forgetting quotations in a string I believe

toxic basin
prisma snow
#
local Part = script.Parent
local db = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
    if db == false then
    db = true
      hit.Parent.Health = hit.Parent.Health - 10
      wait(1)
      debounce = false
    end
end)
#

here, i made it

toxic basin
#

How do you make it like that on discord?

queen escarp
#

Delete humanoid and rewrite it again

toxic basin
#

Instead of just text

prisma snow
#

i cleared out the mistakes, i forgot about the variable.

queen escarp
#

Ugh

#

I’m tryna show it

prisma snow
queen escarp
toxic basin
#

Ok thanks

#

The code still doesn't work though

prisma snow
#

i get why it wont work

queen escarp
#

Rewrite “Humanoid”

toxic basin
#

lua

prisma snow
#

i may think.

toxic basin
#

woah

queen escarp
#

And also change local db to debounce

toxic basin
prisma snow
#

he may did some mistakes.

queen escarp
prisma snow
#
local Part = script.Parent
local db = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
    if db == false then
    db = true
      hit.Parent.Health = hit.Parent.Health - 10
      wait(1)
      debounce = false
    end
end)
vital salmonBOT
#

studio** You are now Level 1! **studio

prisma snow
#

The strings for Humanoid must be " ".

toxic basin
prisma snow
#

Or else roblox studio wont just really get it.

toxic basin
prisma snow
#

The strings are used wrong.

queen escarp
toxic basin
prisma snow
#

The problem is the ".

queen escarp
#

When you copy and paste sometimes the strings don’t register properly

#

Just trust me

toxic basin
#

Mine works when it isn't green

prisma snow
#

The strings are supposed to be " " im sure.

toxic basin
#

Mine is just different colors for that idk why

queen escarp
#

Just try it

prisma snow
#
local Part = script.Parent
local db = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
    if db == false then
    db = true
      hit.Parent.Health = hit.Parent.Health - 10
      wait(1)
      db = false
    end
end)
toxic basin
#
local debounce = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
        if debounce == false then
            debounce = true
            hit.Parent.Health = hit.Parent.Health - 10
            wait(1)
            debounce = false
        end
    end)```
#

That's the code

prisma snow
#

You used “ ” when trying to get the strings.

#

You should use " ".

prisma snow
#

And wait for the results.

toxic basin
#

Oh it is green now

#

Why wasn't it before?

#

What was the difference ?

prisma snow
#

You used “ ”.

queen escarp
#

Try the script now

prisma snow
#

Which is wrong.

toxic basin
#

Still doesn't do dmg

prisma snow
#

It should be " ".

#

Why?

#

I'm sure the code is correct.

toxic basin
#

On the last bit of code

queen escarp
#

Hmm

#

Wait

#

I’ll fix

prisma snow
#

Ah. i forgot

queen escarp
#

Oh

prisma snow
#

It is hard to code on discord..

queen escarp
#

Ok

#

The

queen escarp
prisma snow
#
local Part = script.Parent
local debounce = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
        if debounce == false then
            debounce = true
            hit.Parent.Health = hit.Parent.Health - 10
            wait(1)
            debounce = false
        end
end
    end)
queen escarp
#

I’m so used to it auto filling for me

prisma snow
#

i forgot to put another and

#

You may test it now.

prisma snow
toxic basin
queen escarp
#

Huh?

#

Because this is discord

#

Not riblox studio

toxic basin
#

Oh

#

riblox

#

Now the "Humanoid" isn't green again 💀

little fog
#

@toxic basin

Here, i fully wrote them in roblox studio.

local Part = script.Parent
local db = false

Part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        if db == false then
            db = true
            hit.Parent.Humanoid.Health = hit.Parent.Humanoid.Health - 10
            task.wait(1)
            db = false
        end
    end
end)
prisma snow
#

Hm, i think that may be correct.

little fog
#

Cool.

toxic basin
#

How did we go through 117 messages and this guy comes in here first try lmao

#

How did you do it mr. smile face

little fog
#

Coding

toxic basin
#

🤯

#

Where do you learn from davex?

little fog
#

Devforum, and the Roblox's official scripting website. which Max1 sent.

toxic basin
#

Ok thank you so much

little fog
#

Well, the link.

#

Ah, wait.

#

Also a tip.

#

On roblox studio, press F1.

#

It brings you to the roblox tutorial website.

toxic basin
#

Ah ok

little fog
#

which includes scripting and debounces about this post topic!

toxic basin
#

Thank you, I am really trying to become a coder but it has been a struggle for me

#

I don't know how some people pick it up so easily lol

little fog
#

No problem, i hope you'll get there soon.

toxic basin
#

Do you have any other tips?

little fog
#

I never watched youtube scripting tutorials, but you can get a hand on them.

toxic basin
#

That's what I did and didn't seem to get very far with them 🤷‍♂️

little fog
#

The goal is the progression.

toxic basin
#

How does PSX scripts always work

#

Never fail

little fog
#

What?

toxic basin
#

Pet simulator X

#

on roblox

#

That game never has any errors

little fog
#

A little bit irrelative there, but.

toxic basin
#

Sorry I am just wondering lol

little fog
#

It is a little bit understandable, i dont know that much about that game but its just their skills are BIG, i guess.

toxic basin
#

Alright

#

Well thank you so much for the help

little fog
#

Well, good day.

toxic basin
little fog
#

Haha yeah, i'll see you soon.

toxic basin
#

Cya