#connect
644 messages · Page 1 of 1 (latest)
also did i do smth wrong here
its meant to create part like this but theres nothing there
Connect is a stuff or function thing that makes the function between the () run, the TouchPart represents the part that touched the object
You also forgot to parent it to the workspace
So the part is in the game memory
so it just executes the function when the event happens
** You are now Level 1! **
oh damn yeah
Yes
** You are now Level 4! **
so like this
So the script will get a more clear location
Its ok , i remember the time i was just like you
I dont have any knowledge pf other coding things 💀
I started to code like 2 or 1 months ago
thats cool
Have you tried running the script?
oh yeah just realised it creates multiple parts
cuz theres no specification to create 1
part
Then you need to make a debounce for that
idk what that is
also btw for object position is it based on the centre of object or a corner
i can check existence of the part
if its existence is true then dont create new part
Like
lua Local debounce = true Button.Touched:connect(function(part) Local humanoud = part.parent:findFirstChild("humanoid") If humanoid and debounce == true then do Debounce = false "Your code here"
So, what are you wanting to do..?
Its more easier than checking if a part exists
oh right i see
so when u create a new part set debounce to true
and before making part
check that its false
I think i should explain it more clearly
create a box upon touching a button but im figuring it out
So you set a debounce and set it to true
what does debounce mean tho
Its like switch
i can set name to anything yeah
Like some kind f switch of a light or smth
What does the box do
The box is anything idk it just spawns in the game
i will make it so u have to push it to another button to activate the second button
E
Is there a specific location it needs to spawn at?
Yes there is
this should work
local button = script.Parent
button.Touched:Connect(function(PartTouch)
local humanoid = PartTouch.Parent:FindFirstChild("Humanoid")
local debounce = true
if humanoid and debounce then
local box = Instance.new("Part")
box.Parent = game.workspace
box.Position = Vector3.new(-32, 1, 0)
box.Size = Vector3.new(3, 3, 3)
box.Color = Color3.fromRGB(160, 132, 79)
box.Anchored = false
debounce = false
end
end)
Are you wanting the user to touch the button for it to register, or click the button?
You should set the debounce to false at the first line of the if statement thjng or it will run multiple time and will stop instead of creating only one part
ive figured that part out
Instead of using a flag variable (debounce) to prevent multiple bricks from being spawned, you can use the ClickDetector object's MaxActivations property to limit the number of times the button can be clicked. For example, you can set clickDetector.MaxActivations = 1 to allow the button to be clicked only once.
ah i see
local button = script.Parent
local brickSize = Vector3.new(3, 3, 3)
local brickColor = Color3.fromRGB(160, 132, 79)
local clickDetector = Instance.new("ClickDetector")
clickDetector.MaxActivations = 1
button.Parent = clickDetector
clickDetector.MouseClick:Connect(function(click)
local box = Instance.new("Part")
box.Parent = game.Workspace
box.Position = click.Hit.p
box.Size = brickSize
box.Color = brickColor
box.Anchored = false
end)
its touch based
He is using touched event instead of click detectir
I think you should read it from the beggining
Well, is there a reason for the user to touch the button again?
this still created many parts
** You are now Level 2! **
You cannot use a debounce if you want it to only make one.
You should create the debohnce outside of the function
Or it will set the debounce to true
Everytime the function runs
oh because the touch event is seperate everytime
ill test rn
It's still going to spawn more than one.
Is it working
Just slower.
?
it works ty
Does it spawns more then one?
jump
It doesnt turn back on unless you do it on command
it doesnt
It doesnt spawn the block again right?
yeah i just realised if the box falls out of the map it cant spawn again cuz its still alive so i will make an invisible part underneath and if box touches that then debouce = true
or check the position
Checking the position might be a bad thing idk
Sounds good for me , 70% that it will work
yh i would know how to do that in python but not in lua so ill stick to the check collision its easier
if i need help later can i ask u
thanks ur really helpful
Would you like to accept my friend request?
sure
Ima look for more problems to solve
@split compass noooot quite, but great job!
@true grotto Connect is a a function (method) of Events!
Tried my best , atleast i tried
all events have the connect function, this function takes a function as argument and passes it and parameters for you to work with!
so what does the touchPart represent in this case? It's roblox giving you the part that was touched
cause how useful would it be roblox telling you that you touched "something" if it won't tell you what you touched?
another example of an event is the PlayerAdded I'm sure you have already seen it! it notifies when a player joins the game, and it passes the player that joined!
ah i see thanks
local Players = game:GetService("Players")
Players.PlayerAdded:Connect(function(playerThatJoined)
print(playerThatJoined.Name)
end)
- Players is a roblox service that manages player related things
- Players has the
PlayerAddedevent - As stated, *all events have the
Connectfunction - In this case the
Connectfunction will pass you the player that joined, just like touched with pass automatically the touched part
i can use that for welcome message
Breaking news:local father explains something better than the object browser itself
Fun fact not quite 😅
I mean you can but you should not really
You can, but i think you should understand guis
^^
Oh yeah totally
gui works differently ik
but like even then it's just like a gui message
this would relate
if u wanted a local gui message then
You should use scripts instead of local scripts if you want it to be global
the thing is PlayerJoined fires when the player joins your avatar though, the character in the workspace will take anywere between 3 and 30 seconds to join which means
- Handling Gui's server side is a no no, cause bandwidth usage
- a local script *will miss the PlayerAdded event firing as in it would connect after it fired so it missed it
- you would use a remote event instead to notify the player joined! And then handle that client sided
And the script that makes the x joined message should me in the serverside script thing idk
not necesarilly not because it's global he has to do everything in a server script, cause again bandwidth usage
but in the case of the chat messge yeah sure
since it's just text
how do u differentiate a script and local script
the icon
when u just create a script instance
and the name
there are 3 script instances types
Local Script
Module Script
Script (server script)
which one is this
now be mindful that difference will soon no longer matter cause scripts will have a property to be ran client sided (which is hella fucking stupid imo)
it's in the name
script
that's a server script
and ofc the icon
The server sided scripts icons are white
The local scripts icon are blue
the modules are purple
** You are now Level 5! **
yeah!
You should better note the stuff you learn cause you might forget it someday
could u tell me in which scenario id need which type
For something that is only visible for the player only
Like a gui
Or hitbox
sure you''ll actually encounter this case already, but anything that the player needs to run himself
or needs to be processed by the player locally!
like dead user said, a gui, physics processes, tweens, etc
Keep in mind that locals scripts run only when parented under a players backpack, character , or smth related to player
the following is advanced but the rule of thumb is basically:
- Computations in the server
- Processes in the client (so they are smooth, imagine tween something with 300 ping)
but ofc that's not always the case.
also remember that local scripts are running in your computer not a roblox server
Making local scripts handle some stuff could give exploiters some advantage if they learn to stuff with your local script
so anything that happens in that client script won't replicate back to the server
as in if you color a part red in a client script
it's not gonna change for anyone
just for you
Yeah
no worries, local variables are that
named spaces in memory
ever done math?
that's a variable
name and valuie
Local variables are a value thing that only exists in your script
i know python
Like boolean, number, or work, or objects ect.
yeah
** You are now Level 3! **
exactly
that's how a variable looks in meory
but you also asked
the keyword local
you know scopes?
na
because local is to scope the variable
then don't worry too much about it
just always use local
I think his brain is becoming a spaghetti
don't do this```
x = 10
-- do instead
local x = 10
it happens yeah lol
so i only need to add local when im initiating the variable but if im changing the variable value later i dont need to write local
Mmh,
Yes
i mean i have easier time understanding considering that i have python knowledge
do keep in mind that the same happens w/o local
should i make this a local script then cuz i wanted it to be client based only
local x = 10
local x = 20 --> shadowing a variable, not transforming
---
x = 10
x = 20 --> not shadowing, x is a "global" variable
up to you
I think you should not if its not parebted under something related to a player
Or else it wont run
he can put it on starter player scripts though
Yeah
- Note, local scripts don't run in workspace
hm
i think i should finish this first cuz i havent learnt starter player scripts and that yet
ill ping you both when im done then i have better understanding
Later*
aight later ^^
I know you know a bit of python already
but go over while and repeat loop first
then the for loop
yh im watching all of it
what this guy didnt explain at all what the three values do
i just know it will execute 10 times
Its a loop thing , lemme search it
Solved by incapaz in post #2
That type of loop is called a numeric for loop.
Numeric for loops execute their body for a set amount of times.
The format of one is
for variable = start, goal, increment do end
You start at start, going to goal by increment.
for i = 1, 10 do end
Goes from 1 to 10 in increments of 1. If you don’t provide the increment then it defaults to 1, so adding it yourself is unnecessary.
for i = 0, 5, 0.5 do print(i) end
Will print from 0 to 5, in increments of 0.5.
And the variable increases after each iteration (cycle).
for i in range(10):
for in range is more equivalent to a for i, v in ipairs/pairs/iterator do
it won't actually
the min is 10
the max is 1
the step is 1
your min is already > than the max
so it will not run
for i = min, max, step do
if you wanted that to go backward your step mus be negative
Yeah
he avoided the step now, and yah
by default if you don't put the step parameter
it'll be 1
This man is the scripting library himself
this youtuber..
isnt explaining stuff
i understand he is fetching the players list
but whats i, v
An i, v loop in Lua is a type of for loop that is used to iterate over the elements in a table. The i variable is used to keep track of the index of the current element in the table, and the v variable is used to hold the value of the current element.
** You are now Level 12! **
-- Define a table with some elements
local myTable = {1, 2, 3, 4, 5}
-- Use an i, v loop to iterate over the elements in the table
for i, v in ipairs(myTable) do
print(i, v)
end
In your case, your table would be the players.
@candid hare
do you know why the box is bugging kind of
uh my studio is minimized
not really but you can read on them
server script service is your server script runner container, basically
You would attempt to put all your scripts there
remember to do it yourself and to print it
so it ingrains in you
that type of loop is the most useful and it's likely that a good 70% of your code is gonna be for loops or wrapped around a for loop
up to you I recommend a lightstop game lol
wdym by lightstop game
hm ill try that
** You are now Level 4! **
should i make the lightstop a gui or an object i can do either
whatever you want
specs:
- there is a stree
- there is a lightstop
the lightstop will have the green, yellow, and red colors. if the player tries crossing the street while in red he dies
what if in yellow
well what do you do when the light is yellow?
ofc you press the MF gas pedal and speed up
😂
oh ur the car not the pedestrian
in fact your code should have also errored in the player added event
OH
im so stupid
i just wrote whatever on top of my head
ty bor
bro
i was trying to learn datastores but thats quiet complicated rn so ill start easy
and do ur task
i created this nice gui so far
if i click then +1 speeed
that's complicated, nevermind that for a few weeks
good work
oh my fucking god
@full cairn when i tested game my pc crashed so hard i couldnt do anything for 20 minutes
finally it closed
i didnt get to save it :(
man ffs
oh i got auto save lets go
@full cairn what causing my thing to crash
my studio
the car one seems to be fine
its the kill part
you would get an error
why are you not using your output? 😅
now the error is simple actually ```lua
while true do
that'll exhaust the thread
you need to ad a task.wait() *somewere in the loop outerscope
a cheap way to do it is ```lua
while task.wait() do
-- code
end
many will cringe tho
but offcourse when you need to use the while statement condition
you would put it in the while body outer scope
while condition do
-- code
task.wait()
end
both repeat and while loops require a task.wait statement so they don't massacre the thread
but
when i do the car movement script alone it works
that doesnt seem to be the problem
when i run it with the kill
it crashes
hm lemme try
oh ur right
but my kill isnt working hm
uh
You could watch the dev kings video that is inside the advancet scripting tutorial playlist idk the name sorry
I understood some half of data store in a single vid lol 💀
@true grotto don't you have better things to do with your life
you're trying to become a scripter, not doing some random ass jojo game lol
This is wonderful ^^
so creative!
Straight up going for the game you tryna make is no no for me
much more than I expected for day one
is a no no for anything really gotta start small
send the code!
@jaunty trellis I vouch pyro for S1
I just realized that i can make a red light, green light game 🗿
dude you better be able too 💀
I first thought it was so extremely hard that only pro 5 year experienced dev 2ith a team could make this before i started scripting and forgot about it, here i am realizing that this stuff is not that hard 💀
Reacting with checkmark just incase to save somebody's time and make them know that the OG question is solved
Okkk
Nevermind I go to class no interbet
Done
alr but it might be inefficient cuz its my first time
whats s1
this is car movement
i synced it with the light stop
kill
physical light stop
then the gui scripts
hm what should i make next
hm this will be a challenge but i will attempt to make a simplified blackjack game
Scripter rank 1
basically free tier
but, I really mean you did a great job
code's cleaner than the average roblox scripter that takes comms
I'm for real this code is clean!
💀
whats comm
I really really like the Light Up function!
Btich ofccccc
lmao
I have a folder dedicated to them
this is how throwing your coworkers under the bus look 😉
wtf is this 😭
no fucking clue
bro writing like machine code
** You are now Level 5! **
but with english
look at the for loops and if statement spider web after that
the findGuiObj function
is a fucking mess
and that function makes no fucking sense either
not only is this a problem for people reading the script to comprehend it but it can confuse the scripter himself onces he is working with multiple hundred lines
observatioons
Tweens have an event called Completed
you can wait on those events to fire
that'll yield the thread
preventing it from advancing to the next line of code!
Tween.Completed:Wait()
oh i see
Completed being an RBXScript signal type
has the Wait method
so you can wait on any event like that
ie a touched part
local otherPart = part.Touched:Wait()
it'll return whatever argument the Connect function passes
pretty useful!
this is the entire class documentation
Once method is super useful to make custom leaderboards
or leaderstats
that are made with your own UI's
or in general when you just want to have an event fire Once
oh thats helpful
anyhow you have that arbitrary wait before that
wai(8)
it's better to just use the task.delay function
task.delay(8, function()
while true do
-- code
end
end)
that way you don't yield the thread and don't have arbitrary waits all over the place
hm yeah
mind you I've never put a task.wait() in a script just because
that's a code smell really
but it's convenient!
ill try remember all this even though ill prolly forget but ill prolly forget it cuz i need to put into practical use but experience will be solution for that
hmm very creative!
but what you wanted to do is have some sort of "game state"
by that I mean simply put "have a way to know when the game is in red or green"
since that's the entire game, really
yeah
that way instead of reading something like the part material
you consult the game state
if "red" kill else do nothing
in python u can fetch classes idk abt how cross scripting in lua works
about to disown you and adopt pyro
that would be modules
😂
module scripts
so pretty quick
a module is a script that returns literally almost anything you want, but it has to return 'something'
where
people say module scripts are tables
scroll up, look the video
exactly, THEY ARE NOT, we just use them like so most of the time
so i can make a module script the game state and refer to this to check state across scripts
cause they're mostly used to store classes, libraries, data
yesn't you can do that, but only across the same context
this is because of how require behaves
it is really nice
but wdym get gud
IM STILL BANNED
TELL THAT TO ROBLOX
skill issue
im planning on making simple blackjack game now but totally ui based 👀
ill try my best
dad
Look I'm not the one who told baby yoda was a rpist
LMAOOOOO
that's on you son
I get unbanned in 2 hours
also my life doesnt exactly offer up 4 hours a day sometimes
that sounds more on the complex side, but defo maybe try tackling the simplest form of blackjack
"21"
each get 2 cards
and the one that gets the highest wins
yeah i wont add split and that cuz there would be WAY TOO MANY conditions to check
i tried make python blackjack game and i thought about the 100s of conditions id have to make 😭
actually
i think i was tryna make an auto blackjack basic strat
thats why so many conditions
hahah, existential processing ftw
too many
oh son, when you discover that, you'll be writing almost no if statement
jeuss okay fuck that, no
theres prolly easier way instead of hard coding it with some formula but im not a mathematician lmao
definitely, but you won't save yourself of hardcoding the conditions
w/o some fancy algorithms
again try the simplified blackjack game!
21
yeah
I used to love that with my grandmaw, she beat me every time
she had to luck of the devil
im under 18 i dont gamble but i enjoy the games i turned 100 coins in a game to 1 mil in blackjack
luck
im not planning to gamble irl when i grow up
cuz im aware of the devil that possesses me when i do
Exactly, stay from gambling, instead get other pendejos to gamble their savings in ur games lol
aight son, will go back to my things, great and awsome work!
let me know when you have card game, now keep in mind that even the simplified version is a huge step up in complexity
yeah sure
you can send me a fr
ty bro
Looks like my class after my classmates get out of it
Wish yiu good luck
ive been working on it for a while
im very excited with my progress
it was very mind draining im like 50% done
@full cairn @split compass
im kinda excited to show u this
i tried my best to tackle so much problem solving and i finally got there
i tried to make it look as good as i could
one of my script is 200 lines 😭
thats quite alot considering its only my third day. ngl my script was probably very badly written but thats because i dont have alot of experience, but i tried my best to make it efficient but still messy i think
** You are now Level 6! **
I'll check on this later ^^
thanks
only in 3 days and you're advanced
would this be considered advanced?
heres the script
ik it may be bad and efficient but thats because of my lack of experience but i tried making it as efficient as i could, i could had made it more efficient but i was very tired
it is considered to be advanced
u here @full cairn
** You are now Level 6! **
wow id normally steal these minigames from toolbox now i can make these in like 1 minutes its very easy
this is pretty normal yeah, line count normally hovers around 200-300 lines
can't see the video tho
this is pretty nice!
ah had to be
This is amazing!
like I cannot describe how good of a first lil project this is
hmmm the code is a bit on the gnarly side
but you're showing a lot of progress
I really like where you're going
@jaunty trellis I vouch pyro for S2
@true grotto you need to get a second voucher
consider submitting this
Now do keep in mind that S1 is basically free, and S2 an advanced beginner, if you want to go the road of S3 you need to focus now in your:
- Efficiency
- Code design
- Algorithms
- Project arquitecture
that might take you a few weeks to a few months, but definitely keep tackling this projects, again AMAZING job in the blackjack game!
it looks great ^^
yeah it wasnt very efficient
but with experience ill buildup efficiency
btw how would u personally done this efficiently
i think ill get a bit better before i get S2 because some people made good scripts and are in S1
I ned lvl 1 scripter rol :sad:
why dont u get it
wth im level 2
💀
how
cause making good scripts does not equal rank
you also need the knowledge base
that's why when we rank and you cannot sustain your work, even if it's quality many don't get ranked as high
and as why yeah you're S2, but remember that the road to S3 is exponentially harder!
Forget the role for a second, we are talking concrete knowledge and experience but I'm sure you got this! but there's a lot to learn ^^
yeh you seemed to got a second vouch
literally free role
thanks for the motivation
Only 1 work needed and you get role? Aight ima do it
literally can be a script with a basic result
make a time bomb
Can u give more detail
So I can try make it
Wdym time bomb
well I meant him, it would be trivial for an s2, unless you added some spice to it
just a bomb with a countdown, then it explodes
activted by a button/tool
Sure thing, just waiting for my brother to get off the computer sp i can script and post it here
Scripter 1 role , coming for yo
againt it's a free tier
t i m e b o m b
💀
@dull glen if not time bomb can u tell me smth to make
Idk what to make
as just practice or an actual project
make a placement system or a plugin of some sort
or perhaps a procedurally generated mining game
(small)
a pickaxe and hole with random ores
and when everything is mined, it resets
i made a simple healing item, very glitchy and buggy
guys why don't we use #📜︱scripting instead?
@jaunty trellis give this guy S1 lol
y e s
He replies after a bit
There chats would be muddled up
Here easy to chat
and your work is exposed
so yeah to #📜︱scripting
Can we talk here but send work there
nope
If I stay here I'll have to give special treatment to everyone then, I don't feel like doing that.
Oh right
you already have me on your friends list lol
the only thing that's glitchy is the UI, is it not just a tween? or are you increasing it based it on some value
also you should sync the healing to the animation finishing
i fixed it


