Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Ive seen db and for i before and i want to know how i can use them but i dont know how/what they do?

Asked by 6 years ago
  1. for i =

  2. db =

^^^^^^^^ What do these do

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

"For i=" is the beginning of a loop statement.

A "for" loop counts up to the number you specify. the "i=" is the variable that equals how many loops have been completed so far.

here's an example:

For i=1, 10 do
    print(i)
    wait(1)
end

this code would print 1 and wait a second, then 2 and wait a second, then 3, counting all the way up to ten as it went over the loop.

Read this for a better explanation, and some more useful loops.

"DB" is just a variable. it stands for "debounce", but the name isn't important as it's just a the usual name used by scripters. The only important part is that your debounce value starts equaling "false".

Debounce involves setting a true-or-false statement to ignore repeated inputs on a script. This is usually if you have a button that you don't want excited players pressing over and over and over in quick succession, or giving a gun a "reload" time immediately after firing.

The way you use debounce is:

debounce = false -- immediately, I tell the script "hey, make a boolean (true-or-false) value. It's called debounce. Remember it, I'll need it later!"

function onTouched(hit) -- see the end of the code for what activates this function
    if debounce == false then -- two equals signs means "is equal to".
        debounce = true -- i tell the script that debounce is now true instead of whatever it used to be. Thanks to the above "if" statement, the touch script now gets ignored by any other activations until we turn the debounce variable back to false.

        -- your code goes here.

        debounce = false
    end
end
script.Parent.Touched:Connect(onTouched) -- aha! whenever the brick this script is in is touched, this function "onTouched" runs.

remember that the debounce variable is just a true/false value you're asking the script to remember. it can be called anything. "MyButt" is a good choice- hard to forget when starting out! :P

These are fairly base-level concepts of scripting, though. I recommend looking at some beginner tutorials on the roblox wiki, or the Roblox cookbook (link), which is the way I learned.

Hope this helped!

0
aww man... Was about to write that... GG anyways! :P OfcPedroo 396 — 6y
0
Thx, I cant belive I didn't know that a year ago.... I know much more now lol. BluesteelKd 2 — 4y
Ad

Answer this question