#Player Specific Gate

1 messages · Page 1 of 1 (latest)

fallow brook
#

I want to make this green gate open for the player that steps onto the blue button. The gate should only open for the player that pressed it.

The code shown is the final attempt after rewriting fully 3 times using 3 different methods that all failed.

The script is a local script and is in game.StarterPlayer.StarterPlayerScripts

The door currently opens for everyone client sided but not the server.

The exact instructions for the door in order will be listed below:

  1. Button touched by player
  • For the player that touched the button:
  1. Button changes colour to green
  2. Gate transparency becomes 0.5
  3. Gate CanCollide becomes false
  4. After 5 seconds stages 2, 3 and 4 will be reverted

Thanks to anyone who can help, been stuck on this for hours.

narrow lark
#

why are you so sure that it opens for all players wehn 1 player presses the button

#

@fallow brook

leaden ocean
#

yeah like did you test it with 2 players or more

#

or are you just assuming stuff

next snow
#

Also obv it opens to all players cuz u need to open it on the client

#

Just send a remoteEvent like doorOpen, doorOpen:FireClient(player), and on the local script just have doorOpen and doorCloes

#

Idk whos dumber, you for using player.Name == player.Name, or the people being confused why it opens to only one player

narrow lark
#

they be giving out s1 to everyone who asks for it Clownin

lethal ermine
#

He said he opened it on client

leaden ocean
#

this shi is so funny lmao

fallow brook
thorny haloBOT
#

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

next snow
#

ok i giess im dumber cause i didnt see its a local script lmao

fallow brook
#

Im new to coding on roblox, i started like 3 days ago

leaden ocean
# fallow brook yea

btw why did you put it on starterplayer couldn't you had just put it as a local script for the button?

narrow lark
# fallow brook yea

yeah theres like no way that this opens for everyone if you use a local script

leaden ocean
#

try putting it as a local script for the part instead of like starter player scripts or wtv

next snow
leaden ocean
#

lol

fallow brook
leaden ocean
#

so you put this exact code but just changing the variables as a local script for the part?

thorny haloBOT
#

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

leaden ocean
#

no changes for the script?

fallow brook
narrow lark
fallow brook
narrow lark
gentle maple
#

and stuff

fallow brook
gentle maple
#

or remoteevents

fallow brook
#

i want the door to only open to who pressed it

next snow
#

i dont see a way this script doesnt work lol

fallow brook
#

you can try it for yourself, i can send a link to the game, but it just doesnt work

next snow
#

Hn

gentle maple
#

what type of script is this in

leaden ocean
gentle maple
#

like localscript, modulescript, or a script

fallow brook
#

i dont know what module does

gentle maple
#

modulescript just a container of code that can be used

fallow brook
gentle maple
#

anyways

leaden ocean
gentle maple
#

i dont see how this script doesnt work

leaden ocean
#

but it can be used

#

to store information and stuff

fallow brook
gentle maple
#

well

#

im going to ask

leaden ocean
#

most professional scripters use it

#

'cause it looks good

gentle maple
#

is your friend touching the button

leaden ocean
#

and professional

gentle maple
#

or is it just you

#

or both

fallow brook
gentle maple
#

well thats your reason

fallow brook
#

i touch button and it opens for both, she touches button and it opens for both

gentle maple
#

thats why its opened for your friend

leaden ocean
gentle maple
#

yeah remove that useless if statement

leaden ocean
#

then test it again

#

if it still isnt working let us know

gentle maple
#

its basically doing like

#

if name==name then

leaden ocean
#

just put the door open function without any statemnents

fallow brook
leaden ocean
leaden ocean
#

is remove the if statement

gentle maple
#

thats literally it

leaden ocean
#

and put the door open function alone

fallow brook
leaden ocean
#

it's not quantum physics

fallow brook
#

i removed the if statement and also tried other ways around it

next snow
#

it works for me, its basically the same as yours

leaden ocean
#

well then let me check

fallow brook
thorny haloBOT
#

studio** You are now Level 2! **studio

leaden ocean
#

i know what he did wrong

#

he didn't set the local player

#

i mean that's kind of like the only difference

#

even if what i'm saying is dumb

#

there's no other difference than that

#

i'm not like a very good scripter

#

so i don't rlly know most of this technical stuff for local player and stuff

next snow
#

this is what i did

leaden ocean
fallow brook
#

okay wait im logging on, im gonna try some of the stuff you guys are recommending

leaden ocean
#

that's probably the problem

leaden ocean
#

you gotta use the local player

fallow brook
#

whats a player instance

round trail
leaden ocean
gentle maple
#

a player instance is literally a player

fallow brook
#

so how do i switch it to local player

round trail
#

alrighty

leaden ocean
#

only that get service is more modern

#

and more used

fallow brook
#

okay 1 sec let me read what you sent

gentle maple
#

floppzy use the task library it will make your life easier (at least it did for me)

next snow
fallow brook
round trail
next snow
#

Also if for some reason you rename a Service, :GetService will get it, even if u change the name

narrow lark
#
local section = game.Workspace.Obby.Section1
local startButton = section:WaitForChild("StartButton")
local startWall = section:WaitForChild("StartWall")
local finishWall = section:WaitForChild("FinishWall")

local isOpen = false
local delay = false

local function changeWallState()
    isOpen = not isOpen

    startWall.CanCollide = not isOpen
    finishWall.CanCollide = not isOpen

    startWall.Transparency = isOpen and 0.5 or 0
    finishWall.Transparency = isOpen and 0.5 or 0

    startButton.BrickColor = BrickColor.new(isOpen and "Lime green" or "Electric blue")
end

startButton.Touched:Connect(function(hit)
    if delay then return end

    local character = hit.Parent
    if not character:FindFirstChild("Humanoid") then return end

    delay = true
    changeWallState()

    task.wait(2)
    delay = false
end)

try this and try to understand why its better and how it works @fallow brook

fallow brook
#

okay let me test if it works first

gentle maple
next snow
round trail
#

oh okay

narrow lark
fallow brook
#

can someone join my game to test it please?

gentle maple
fallow brook
#

I need a second player

gentle maple
#

ill join i guess

fallow brook
#

okay thank you

gentle maple
#

dm profile

#

wth does BrickColor.new(isOpen and "Lime green" or "Electric blue") do

narrow lark
gentle maple
#

yeah you can also do that

gentle maple
#

i forgot about that

narrow lark
fallow brook
#

okay so how do i do this 2 client thing

next snow
narrow lark
#

short for:

if isOpen then
    Limegreen
else
    Electric blue
end
gentle maple
#

for me

next snow
#

no lol that won't work

#

i think

fallow brook
narrow lark
narrow lark
fallow brook
#

So when i press the button it opens the door and then when i press it again it closes

#

how do i go about making it so after 6 seconds it closes automatically

narrow lark
#

o

#

was that a thing

gentle maple
#

after the task.wait

next snow
fallow brook
#

what is the changewallstate function?

next snow
#

@fallow brook js watch yt videos that teach you stuff, to script anything u need to know what a function is lol

fallow brook
next snow
#

how are u advanced script, but u dont know what a function is

fallow brook
#

but i just dont know why the client sided door wasnt working

fallow brook
#

iv never used it

next snow
#

😭

fallow brook
#

what does it do?

narrow lark
#

uhm it changes the state of the wall?

gentle maple
next snow
gentle maple
#

the code inside the changeWallState just does

fallow brook
#

ohhhh, i read it wrong

#

im sorry

#

i get it now

gentle maple
#

the variable equals the opposite of teh variable

fallow brook
#

I thought when you were talking about it that you meant it was a line similar to "FindFirstChild()" or something

gentle maple
#

no clue how you got that but its okay

fallow brook
#

okay so, how do i make this so instead of it disabling on button press it disables after 5 seconds

narrow lark
#

pretty simple

next snow
#

I still dont get how he's "advanced" but doesn't know hwo to use functions

gentle maple
#

change task.wait(2) to task.wait(6)

#

then add the changeWallState function after it

#

pretty sure thats how it works

#

i hope

fallow brook
#

im nowhere near advanced

#

im terrible

next snow
gentle maple
#

i think beginner was too easy for him

next snow
#

theres a reason why its called advanced

round trail
#

i mean atleast u know syntax right

next snow
#

Dude it's not "too easy" for him if he doesn't know how to use waits lol

fallow brook
fallow brook
#

the whole thing

fallow brook
#

even went through and studied it

next snow
#

but how do u not know how to do task.wait

fallow brook
#

like i said iv been doing code for 3 days

fallow brook
#

i know what task.wait is

round trail
narrow lark
round trail
#

do u want it not to delay the rest of the code?

fallow brook
#

what im saying it, this script makes it so the wall opens on button press and then disables on second button press

gentle maple
#

WAIT

fallow brook
#

how do change that to be just a delay

next snow
gentle maple
#

change the delay debounce name

fallow brook
gentle maple
#

to like

#

idk

#

DelayDebounce or something

round trail
#

that would be clearer

narrow lark
round trail
#

i guess

narrow lark
#

o

#

shit

#

yea

#

change that to debounce

gentle maple
#

idk how to explain it but just change it to something else

#

or else you get htis

#

this

fallow brook
#

i just removed the debounce

thorny haloBOT
#

studio** You are now Level 3! **studio

narrow lark
gentle maple
#

bruh

round trail
gentle maple
#

this code

#

if DelayDebounce then return end

#

i just renamed it to delaydebounce

#

anyways

#

the code

next snow
#
local function changeWallState()
  startWall.CanCollide = false
  startWall.Transparency = 0.5

  finishWall.CanCollide = false
  finishWall.Transparency = 0.5
  
  task.wait(6)
  
  startWall.CanCollide = true
  startWall.Transparency = 0

  finishWall.CanCollide = true
  finishWall.Transparency = 0
end

startButton.Touched:Connect(function(hit)
 local Char = hit.Parent

if Char:FindFirstChild("Humanoid") then
  changeWallState()
end

end)
#

there, thats as simple as it gets

#

i dont see a way to make it more simple

gentle maple
#

prevents it from changing the wall state if delay is still true

narrow lark
# gentle maple

I wrote the code in a txt file and didnt realize that i named it delay instead of debounce mbmb

next snow
#

still doesn't matter the name of delay, you only change wallstate once after they touch the button

gentle maple
#

anyways

#

its literally just this

next snow
#

dude he can add it himself if he's allready past the basics

fallow brook
#

okay so, how do i test using 2 clients inside of studio

#

because someone said i could do that

narrow lark
gentle maple
next snow
#

Ok, im wasting my brain power here 😭 bro doesn't know how to use functions or task.wait

gentle maple
fallow brook
next snow
#

Learn before u try making stuff, simple as that. you need to know what functions and variables are, At the very least

fallow brook
#

is that bad?

gentle maple
narrow lark
fallow brook
gentle maple
#

but its alright

narrow lark
fallow brook
round trail
spring robin
#

how much better is it to use task.wait over wait

next snow
#

task.wait is just more optimized, doesn't matter if ur making a single door and you don't know how to do anything 😭

gentle maple
#

accurate

#

idk how to describe it

fallow brook
#

so in the new UI how do i use 2 clients to test the door?

round trail
gentle maple
#

im pretty sure that

#

task.wait uses heartbeat but wait() doesnt

next snow
#

actually mb, wait is 0.3, now 0.03

#

wait() is 1/3rd of a second, task.wait() is 1/60th

narrow lark
spring robin
#

is render stepping un optimized or is it good to use for local scripts

next snow
gentle maple
#

@fallow brook how do you not know how to use studio features

fallow brook
gentle maple
#

the old one?

fallow brook
#

we went over this

gentle maple
#

just said you arent used to the new one but i think you just click UI no?

narrow lark
leaden ocean
#

IF YOU DON'T USE TASK.WAIT YO'RE STUPID

next snow
leaden ocean
#

there' also the heartbeat one but i don't rlly remember it well or what it did

next snow
#

they all wait a frame, but while true do wait() yields the code for a minimum of 2 frames, but task.wait, renderstepped,heartbeat and stepped will yield for only one frame

spring robin
#

holy ball knowledge

gentle maple
#

all you need to know is just task.wait is better than wait()

#

confirmed

narrow lark
fallow brook
#

Can someone just tell me how do use 2 clients for testing in the new roblox UI??

gentle maple
#

no clue how it works in the new ui

#

trial and error i guess

narrow lark
#

go to "Client & Server" and select 2 persons

fallow brook
leaden ocean
#

IT'S FRICKIN' IMPORTANT YOU HEAAR ME?

narrow lark
narrow lark
gentle maple
#

guys just stop talking about wait() and task.wait() altogether

narrow lark
gentle maple
thorny haloBOT
#

studio** You are now Level 7! **studio

leaden ocean
narrow lark
gentle maple
narrow lark
# fallow brook

red box then click test, select "Player & Server" and then 2 persons

gentle maple
#

didnt even see that file edit view plugins test window and help there

narrow lark
#

yes

gentle maple
#

looks like it

fallow brook
#

ohhhh i see

#

thank you zyos

narrow lark
#

npnp

fallow brook
#

So just a quick problem

narrow lark
#

just a quick one?

fallow brook
#

With the current script im still getting the same issue with the other player being able to see the wall open

#

this is only supposed to effect one player

narrow lark
#

show me ur explorer

#

like send a screenshot of ur explorer showing me the script

fallow brook
#

okay

#

the one called "Section1Start"

gentle maple
#

show whats ingame

narrow lark
#

how the hell is it open for everyone

#

thats like impossible

gentle maple
#

i think i know the problem

fallow brook
gentle maple
#

its in starterplayerscripts (i dont know)

fallow brook
#

left and right are showing

#

maybe i try put it into workspace?

gentle maple
#

put the script into like startergui and then try again

#

localscripts do not work in workspace

fallow brook
#

okay i try in gui

gentle maple
narrow lark
#

bro 😭

gentle maple
#

CHANGE IT TO LIKE DEBOUNCE

fallow brook
#

same issue with new location

narrow lark
gentle maple
#

i would still do it

narrow lark
#

nah like

#

ur game weird

fallow brook
#

where is the delay debounce name

gentle maple
#

ok bro

#
local delay=false

change to like
local debounce=false

narrow lark
#

show me the obby model

fallow brook
#

should i change the others too

narrow lark
#

extend it

#

and make a screenshot

fallow brook
narrow lark
#

open parkour folder in section 1

fallow brook
narrow lark
#

LIKE

fallow brook
#

im so lost

narrow lark
#

me too

gentle maple
#

me three

narrow lark
#

OMG

#

I KNOW

#

WY+

#

WHY

#

IM SO SMART

fallow brook
#

WHY

#

just before you tell me

#

after i changed "delay" to "debounce" it stopped working

thorny haloBOT
#

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

narrow lark
#

YO FUCK US

#

OMG

#

WE ARE SO STUPIDIDIDIDI

gentle maple
fallow brook
#

like this

gentle maple
#

i thought it was the other one someone else provided

fallow brook
#

this is

#

this is zyos code i think

#

or yours

#

i forgot

gentle maple
#

use task.wait(5) or else @leaden ocean will 🔪 you

fallow brook
#

okay i did that

gentle maple
#

and remove that unnecessary task.wait(2)

fallow brook
narrow lark
#

alr Floppzy im booting roblox studio just for you

gentle maple
#

now try i guess

narrow lark
fallow brook
#

it now only works when its in startGUI

#

when its iun starterPlayer it doesnt

gentle maple
#

show studio and run two clients

narrow lark
fallow brook
narrow lark
#

js gimme like 2mins

fallow brook
#

why it no work

#

also why doesnt it work when its in starter player anymore?

#

im so confused im just gonna wait for zyos

narrow lark
#
local section = game.Workspace.Obby.Section1
local startButton = section:WaitForChild("StartButton")
local startWall = section:WaitForChild("StartWall")
local finishWall = section:WaitForChild("FinishWall")

local isOpen = false
local debounce = false

local function changeWallState()
    isOpen = not isOpen

    startWall.CanCollide = not isOpen
    finishWall.CanCollide = not isOpen

    startWall.Transparency = isOpen and 0.5 or 0
    finishWall.Transparency = isOpen and 0.5 or 0

    startButton.BrickColor = BrickColor.new(isOpen and "Lime green" or "Electric blue")
end

startButton.Touched:Connect(function(hit)
    if debounce then return end

    local character = hit.Parent
    if not character:FindFirstChild("Humanoid") then return end
    
    local player = game.Players:GetPlayerFromCharacter(character)
    if player.Name ~= game.Players.LocalPlayer.Name then return end

    debounce = true

    changeWallState()
    task.wait(6)
    changeWallState()

    debounce = false
end)

BOOOOOOOOOOOOOOM

fallow brook
#

what was the problem

fallow brook
#

well

leaden ocean
#

i will EXTERMINATE him just like syndrome did

gentle maple
#

I LITERALLY DID THAT

fallow brook
#

uhhhh

leaden ocean
#

with the super heroes

fallow brook
gentle maple
#

BUT FLOPPZY REMOVED THE "ISOPEN" DEBOUNCE

narrow lark
#

wehn a player touches the part the other local script also reconginzes this touch so we have to filter if the touched player is the local player

fallow brook
leaden ocean
narrow lark
#

MY SCRIPT SHOULD FIX IT

gentle maple
#

and see

#

what happens

fallow brook
leaden ocean
#

can yall give me a quick summary of what's wrong

leaden ocean
#

can yall give me a quick summary of what's wrong

#

can yall give me a quick summary of what's wrong

fallow brook
#

starterGUI

narrow lark
#

TS RASCAL DID IT

leaden ocean
#

can yall give me a quick summary of what's wrong

fallow brook
narrow lark
#

or im crashing out

leaden ocean
gentle maple
#

so it only works in startergui or what

fallow brook
#

wait i fixed it

narrow lark
#

USE MY FUCKING CODE

fallow brook
#

i put it under starterPlayer and now starterPlayer.StarterPlayerScripts

gentle maple
narrow lark
fallow brook
#

okay so your code works but let me test on 2 players

gentle maple
#

why would you put it under starterPlayer

narrow lark
#

IT WILL WORK SO WELL

narrow lark
fallow brook
narrow lark
leaden ocean
#

idk how something this simpel was this hard to do sob2k pray4k

gentle maple
fallow brook
#

zyos might be our hero

gentle maple
#

its literally just

fallow brook
gentle maple
#

idek

leaden ocean
#

btw this 2k emojis are FIRE

narrow lark
#

450 messages btw

leaden ocean
gentle maple
#

@fallow brook the problem was you literally removed the entire isopened debounce

leaden ocean
gentle maple
#

and removed its existence

narrow lark
#

fr tho this bug isn't very easy to understand

gentle maple
#

from humanity

fallow brook
#

okay so just really quick

leaden ocean
#

bump

fallow brook
#

and im really sorry because im stupid and messed up alot

#

but

narrow lark
leaden ocean
fallow brook
#

can someone explain what isopen debounce is?

leaden ocean
#

this should've been an easy fix

#

and it took 450+ messages

gentle maple
fallow brook
#

my gf has been waiting for me for an hour, its 2am 😭

gentle maple
leaden ocean
gentle maple
#

IN THE CHANGE WALL STATE FUNCTIon

leaden ocean
#

or did she

gentle maple
#

ISOPEN = THE OPPOSITE OF ISOPEN

#

THEN ITS PRETTY SELF EXPLANATORY FROM THERE

leaden ocean
#

0 = the opposite of 0

fallow brook
#

okay wait lemme read through

leaden ocean
#

that's what you're telling us

narrow lark
#

Her for everyone wondering what the bug was:

We have 2 Clients, wehn a person touches this both client scripts detect: Oh theres a touch. So both open the door, to fix this we need to check if the player who touched it is the same player who we are opening the door for

leaden ocean
#

sob2k pray4k y

next snow
#

Just ask chatgpt, "tell me what this script does" and paste ther script

gentle maple
fallow brook
#

so im confused on what this means

leaden ocean
#

it's kinda confusing what you said

fallow brook
leaden ocean
#

😭

#

or i'm js stupid

gentle maple
fallow brook
#

what does it mean by isOpen and 0.5 or 0

next snow
#

bruh

gentle maple
#

if isopen is true then transparency is 0.5

next snow
#

ask chatgpt twin

gentle maple
#

if isopen is false then

#

transparency is 0

leaden ocean
fallow brook
#

ohhh so it works like a flipflop basically

leaden ocean
#

'cause you better prepare for that invasion that bouta come

gentle maple
fallow brook
#

okay thank you

#

so the first value is for true and the second value is for false

gentle maple
#

something like that

#

ask markec he knows

#

or she

leaden ocean
gentle maple
#

no discriminating

narrow lark
#

yes

fallow brook
#

so its a very short way of saying:
if isOpen == true then
startWall.Transparency = 0.5
else
startWall.Transparency = 0
??

narrow lark
fallow brook
#

wow

#

thats actually helpful

#

thanks alot

#

youre a legend

gentle maple
#

wait my brain turned off for a sec

#

it was bc markec said an explanation of it

#

not the code

#

😔

fallow brook
#

im gonna study your code tomorrow and try to learn the things i dont understand

gentle maple
#

what i meant to say was

#

ask zyos he knows

narrow lark
#

js cause hes s1woe

gentle maple
#

frfr

fallow brook
#

I think its funny how the s1 Markec was less helpful and kind than the rest of you

next snow
leaden ocean
#

let me try it out rq

fallow brook
#

Thank you rascal and zyos and Ryker, youve been a big help!

fallow brook
next snow
#

I feel insulted

fallow brook
#

Anyways, im gonna set this to completed now, best of luck to you all!

leaden ocean
gentle maple
#

554 messages 💔

lethal ermine
leaden ocean
#

559 now

#

560 now

narrow lark
leaden ocean
#

FIRE MOD

#

absolute masterpiece

#

but um

#

HOW THE FUCK

narrow lark
leaden ocean
#

IS THAT A HEAR ME OUT

narrow lark
leaden ocean
#

like why the fuck do you wanna reproduce with that shi

next snow
narrow lark
#

yes

#

cause im not creating 3 projects just to leak my source code🙏

leaden ocean
#

it's soo freakin' coo

#

cool*

narrow lark
#

yall dont have any perks with s1 you cant even write in pro scripting 😭

next snow
leaden ocean
#

how can i get to that channel

narrow lark
leaden ocean
#

how do i get the rank

next snow
narrow lark
leaden ocean
#

i'm not oding allat

narrow lark
#

fr

next snow
#

also i applied for s1 like, 2 years ago

leaden ocean
next snow
leaden ocean
#

yk them recreations?

next snow
#

no

leaden ocean
#

well i'm making a recreation of rlcraft 😄

narrow lark
leaden ocean
#

let's be honest

#

most of developers nowadays use chatgpt for aiding and stuff

#

some even use it for the whole game

narrow lark
#

idk how big these projects need to be for s2

leaden ocean
#

does that count

#

it's got 10 nights

#

and full functionality

narrow lark
#

nah

leaden ocean
#

wtf you mean nah

#

it took me MONTHS to make it

next snow
#

not that big, i sent a scuffed flee the facility game, and i got s1, i used like 2 models and 4 scripts in the game, its prtetty easy

leaden ocean
#

even tho fnaf is dead

next snow
#

They said i might be S2, but dint give 🙁

leaden ocean
#

and no one cares about it in roblox

leaden ocean
next snow
#

when meghan fox chica

leaden ocean
#

the chica is quite uhm

next snow
leaden ocean
#

how do i make this family friendly

#

quite attractive

narrow lark
leaden ocean
next snow
#

s2 is pretty easy

leaden ocean
#

i mean multiple scripts

#

it's got cameras,

#

power

narrow lark
lethal ermine
#

Are you guys trying to make this thread 1000 messages

leaden ocean
#

and more

next snow
#

ye

narrow lark
#

3am btw took 1:30h to figure out the bug

next snow
#

not even a bug ,its everyone just being stupid 💔

leaden ocean
#

true

#

true

#

true

narrow lark
#

fr tho its kinda easy now that you know what it is but without knowing you like never figure this out

gentle maple
narrow lark
#

he was on the right pat

#

h

gentle maple
#

something like that

#

just that

#

nevermind

narrow lark
#
local player = game.Players:GetPlayerFromCharacter(character)
if player.Name ~= game.Players.LocalPlayer.Name then return end

I mean he was close

gentle maple
#

yea

narrow lark
#

kinda

#

look at the bottom of this @leaden ocean , someone sent this in yesterday

gentle maple
#

what does _G even do

narrow lark
#

you wont need it

gentle maple
#

i just did

narrow lark
#

and im telling you you dont need to know cause you will never use it

gentle maple
#

ok its basically a modulescript from every script

#

i said that horribly

narrow lark
#

huh

gentle maple
#

but

#

yeah

narrow lark
#

no its a global variable

gentle maple
#

where you can use variables from other scripts

#

thats what i meant

narrow lark
#

yeah idk its a global variable but its like wait() its there but its ass

gentle maple
#

_VERSION is place version right

#

or sum

#

ok anyways no need of these useless variable stuff

narrow lark
#

idk

#

never used it

narrow lark
gentle maple
#

like

#

type and typeof

narrow lark
#

no

#

like

#
local myNewString : String = "example"
gentle maple
#

i do that but with parameters in functions and sh

#

like

#
local function blahblah(player : Player, string : String, blah : IntValue)
end
narrow lark
#

yeah

gentle maple
#

also what does it mean if people do like

#
local hi="idek"
local k, p = hi
#

idk what the second line does

narrow lark
#

you define 2 variables at once
so its short for:

local i = "idek"
local k = hi
local p = hi
gentle maple
#

oh

#

so what does it mean if like

#
local success, errormsg = pcall(function()
    blah blah blah
end)
#

and like

#
if success then
  blahblah
elseif not success then
  print(errormsg)
end
warped citrus
#

why is this over 650 messages for ".cancollide=false in a localscript"?

narrow lark
#

if theres an error in the pcall it won't break the script but catch it

narrow lark
gentle maple
#

yeah

#

now this is just a chatroom

#

after it got solved

warped citrus
#

mmk 🤷

narrow lark
gentle maple
#

so success and errormsg both equal pcall

thorny haloBOT
#

studio** You are now Level 8! **studio

gentle maple
#

?

narrow lark
#

huh

#

error message is nil if there were no errors i think and success is either true or false

gentle maple
#

so how come

local hi="idek"
local k, p = hi
``` k, and p, equal the same
#

but success and errormsg dont

narrow lark
#

ye

gentle maple
#

is like

narrow lark
#

i think pcall returns something like this:

return true, error("nothing")
gentle maple
#

oh

#

so success is like an outcome of the errormsg

#

or pcall

#

somethign like that

#

something

narrow lark
#

yes

#

cuz pcall is a function it returns something

#

and that is success and errormessage

gentle maple
#

how does task.spawn() work (not as a function just plain ol task.spawn())

high haven
#

if u touch the button add a tag to the player. if the player has that tag they can walk through the gate

#

i think ts would work

high haven
#

oh ok

narrow lark
#

okay imagine this:
You have a stack of plates, every plate is 1 line of code and you can only take 1 plate off at a time (execute 1 line of code per time), wehn task.spawn comes in you take the plates (amount of lines in the task.spawn function) and put it to the side then you can take off 1 plate on each stack at a time. So task.spawn lets you execute stuff while not stoppin the main script yk

gentle maple
#

thats task.spawn(function() i know how that works

narrow lark
#

o

gentle maple
#

but ive seen peolpe do something like

#

task.spawn(playerAdded, player)

#

in profile service

#

like this for example

narrow lark
#

im guessing profile service takes longer to setup and thats why we are creating a second task so the script doesnt need to stop

gentle maple
#

ok so how does this example work

#

also playerAdded is a local function

narrow lark
#

short for:

task.spawn(function()
    playerAdded(player)
end)
gentle maple
#

oh

#

i was thinking that also

#

but still asked

#

just incase

warped citrus
narrow lark
#

ye

narrow lark
#

they dont?evilcat

warped citrus
#

;compile lua lua local hi="idek" local k, p = hi print("k=",k,"| p=",p)

narrow lark
#

omg they dont

frigid gladeBOT
#
Program Output
k=idek| p=nil

narrow lark
#

yea

#

mbmb

gentle maple
#

how come p equals nil

warped citrus
gentle maple
#

oh

narrow lark
#

ye

warped citrus
#

second value not specified so it is nil

#

like doing just local x

gentle maple
#

OHHHH

#

ok

#

so like

#
local x="blah"
local y="blah2"
local k,p=x,y
warped citrus
#

you usually won't ever use this except when line compression or doing swap

#

;compile lua lua local x,y=5,200 print(x,",",y) y,x=x,y print(x,",",y)

frigid gladeBOT
#
Program Output
5,200
200,5

warped citrus
#

oh, it does come up when functions have multiple return value

gentle maple
#

what does swap mean in this context

warped citrus
gentle maple
#

ok

warped citrus
#

without doing x,y=y,x you need a 3rd temporary variable

#

for local x,y=2,5 local temp=x x=y y=temp same thing

#

why go through all that trouble when you can just write x,y=y,x instead

narrow lark
warped citrus
#

the expression is evaluated as a whole, not in parts

narrow lark
#

yea

gentle maple
#

if it was in parts then would x=y

#

or something like that

warped citrus
#

you'd need temp variable again

#

though tbh pretty rare you need to manually swap variables

#

usually happens when sorting tables, which you have table.sort to do that for you

#

tbl[a], tbl[b] = tbl[b], tbl[a]

gentle maple
#

just to clarify

#

another thing

#

i am going to ask

#
for i, v in randomfolder:GetChildren() do
    local onechild=randomFolder[i]
    
end```
#

why would this not work

#

wait

#

nvm

#

i think i know why it wouldnt work

warped citrus
#

local onechild=randomFolder[v.Name]

gentle maple
#

what if like

narrow lark
#

take it back

gentle maple
#

i wanted to do it with I

#

i

#

would it be randomFolder:GetChildren()[i] ?

warped citrus
#

the i in when looping through GetChildren is arbitrary and doesn't mean anything

#

the order is also not guaranteed

#

do not rely on it

narrow lark
#

you'd have to index with numbers and not strings right

warped citrus
gentle maple
#

oh alr

warped citrus
#
local kids=randomFolder:GetChildren()
for i,v in kids do
  local onechild=kids[i]
end```
#

but if you're iterating like that you wouldn't use pairs, you'd use numeric iterator instead
for i=1,#kids do local v=kids[i] end

#

since in the pairs loop you already have the value of v

gentle maple
#

what is the difference between ipairs and pairs

#

still wondering

warped citrus
#

ipairs is for consecutive arrays to be iterated in order

gentle maple
#

i heard one is for arrays and one is for dictionaries

warped citrus
#

pairs is unordered

gentle maple
#

so pairs is practically random

#

and ipairs is the same

#

or something

warped citrus
#

i avoid using the word random very intentionally - it is not random

#

but it also doesn't have an order

#

best you can say is it has "memory order"

#

which is almost random but not quite

#

if you want proper random order you have to do things to the table or iterate it in a certain way to get proper randomness

#

can't just assume it's random, you need to deliberately make it random.

#

roblox merged ipairs and pairs so not using either will use roblox's version of ipairs by default

#

which works on dicts as well as arrays and tends to internally sort things

#

-- you shouldn't rely on that though. if you want ordered data, you should always sort it yourself to guarantee the order you intended

gentle maple
#
local noclue={
  "Hi"
}
local noclue2={
  ["Hi"]={},
}```
which one is an array and dictionary or none
warped citrus
#

first one is an array the second is a dict

gentle maple
#

now that i think about it

#

its kinda self explanatory

warped citrus
#

yep only difference is string keys

gentle maple
#

because lets say arrays in math are just numbers with nothing to it

warped citrus
#

well

#

i mean

#

you can use anything as a key

gentle maple
#

but dictionaries are like words with the meaning

warped citrus
#

;compile lua lua local a={foo="bar"} local t={ [a]="thing" } print(t[a]) print(a.foo)

frigid gladeBOT
#
Program Output
thing
bar

warped citrus
#

including other tables as a key.

#

not sure about nil tho but hey always try stuff out and see what happens

#

;compile lua lua local t={ [nil]="foo" } print(t[nil])

frigid gladeBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:1: table index is nil
stack traceback:
prog.lua:1: in main chunk
[C]: in ?

warped citrus
gentle maple
warped citrus
gentle maple
#

also is it just higher ranks that can use compile

warped citrus
gentle maple
#

;compile lua

print("hi")
frigid gladeBOT
#
Program Output
hi

gentle maple
#

ayy

#

it worked

warped citrus
#

just keep in mind compiler bot uses lua, not roblox's luau, so some features won't work like the for k,v in t do will be unrecognized, you must specify iterator like pairs()

gentle maple
#

;compile lua

local myTable={}
local myTable2={
  "TheDevKing",
"BrawlDev"
}
table.insert(myTable, myTable2)
for i, v in pairs(myTable) do
  print(v)
end
frigid gladeBOT
#
Program Output
table: 0x62903828fd40

gentle maple
#

oops

#

;compile lua

local myTable={}
local myTable2={
  "TheDevKing",
"BrawlDev"
}
table.insert(myTable, myTable2)
for i, v in pairs(myTable2) do
  print(v)
end
frigid gladeBOT
#
Program Output
TheDevKing
BrawlDev

gentle maple
#

hm

#

;compile lua

local myTable={}
local myTable2={
  "TheDevKing",
"BrawlDev"
}
table.insert(myTable, myTable2)
for i, v in pairs(myTable) do
  print(myTable)
end
frigid gladeBOT
#
Program Output
table: 0x5c5ec9adcee0

gentle maple
#

huh

#

wait nvm i know why it would do that

#

;compile lua

local myText="hello world"
for i=1, #myText do
    print(string.sub(myText,0,i)
end
frigid gladeBOT
#
Program Output
/opt/wandbox/lua-5.4.7/bin/lua: prog.lua:4: ')' expected (to close '(' at line 3) near 'end'

gentle maple
#

oops

#

;compile lua

local myText="hello world"
for i=1, #myText do
    print(string.sub(myText,0,i))
end
```\
frigid gladeBOT
#
Program Output
h
he
hel
hell
hello
hello 
hello w
hello wo
hello wor
hello worl
hello world

warped citrus
#

you can edit btw and compilebot updates

#

or just use this https://luau.org/demo

warped citrus
#

outside of roblox you have to write your own

gentle maple
#

if i have to write my own how would it work

warped citrus