#pls help pls im trying to make /summon

1 messages · Page 1 of 1 (latest)

wild comet
#

im trying to do a /summon command and if the user enters something on that table, it continues. if it isnt, then dont continue

local scripts = {
    "Scription",
    "Las Script",
    "Module Scription",
    "Record Scripta",
    "Local Scription",
    "Los Script Combination",
    "La Scripta",
    "Remote Eventa",
    "Las Scriptiosos",
    "Le Click Detector"
}

local lucky_blocks = {
    "Common",
    "Uncommon",
    "Rare",
    "Epic",
    "Legendary",
    "Mythic",
    "Script God",
    "Secret"
}

local admin_lucky_blocks = {
    "Original",
    "Admin",
    "Hacker"
}

local weathers = {
    "Meteor",
    "Aurora",
    "Taco",
    "Popcorn",
    "Lazer",
    "Star Rain"
}

local editions = {
    "Common",
    "Rare",
    "Epic",
    "Legendary",
    "Mythic",
    "Script God",
    "Secret"
}

local variations = {
    "Normal",
    "Gold",
    "Diamond",
    "Rainbow",
    "Lava",
    "Galaxy"
}

game.Players.PlayerAdded:Connect(function(plr)
    plr.Chatted:Connect(function(msg)
        local args = string.split(msg, " ")
        local command = args[1]
        local target = args[3]
        local item = args[2]
        
        if command == "/summonscript" then
            
        end
    end)
end)```
#

@main ruin pls can u help me? sorry if im not allowed to ping anyone here

main ruin
wild comet
wild comet
main ruin
#

So we have an item inside a table , I believe you just have to loop theough the items inside of said table

#

Then check inside the loop if that element Inside the table matches what the player sent

chrome echo
#

wouldnt it be better to use a dictionary here

dusky swallowBOT
#

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

main ruin
chrome echo
#

then you dont gotta loop through you can directly index it

main ruin
#

Wait yeah right

chrome echo
#

one check instead of ~10

wild comet
# main ruin Wait yeah right

if command == "/summonscript" then
if table.find(scripts.lower(), item.lower()) then
print("hi it worked :3")
end
end

#

scripts.lower dont work

#

is it string.lower(scripts)?

chrome echo
#

youd have to run through them individually

tight sparrow
#

hashmap

wild comet
#

how do i do that

tight sparrow
#

[key] = value

#

in this case itd be

#

[nameofscript] = required module

wild comet
#

can you please rewrite my code to do that? im not so good at following sections of code

tight sparrow
#

no u gotta learn

wild comet
#

idk what that is

#

like i struggle a lot with putting bits of code into a full line

main ruin
wild comet
#

or is that irrelavent in tables?

chrome echo
#

it is relevant

#

like @tight sparrow said use a map

#

itll make your life way easier

wild comet
#

i dont know what a map is, i dont know that much about coding and its hard for me to add sections of code into other sections

wild comet
#

actually its fine ill just make it case sensitive

chrome echo
#

anyway basically its an array, but you define the key value pairs

#

dumbed down ^

main ruin
#

Wait I have an idea

wild comet
chrome echo
#
local a = {
["Hallo"} --[[The Key]] = "World" --[[The Value]]
}

print(a["Hallo"]) -- prints "World", can access directly with the key

for k, v in a do -- can loop similarly to a normal array
    print(`{k} {v}`) -- prints "Hallo World"
end

main ruin
# wild comet hm?

Use dictionaries just like she said but make them lowercased , then use .lower() for the item string , now check for script[item]

#

I suggest the table types to be of boolean and set to true

#

So something like

chrome echo
main ruin
#

Local script = {
La scripta = true
}

chrome echo
main ruin
tight sparrow
#

yk

#

the better way

chrome echo
wild comet
tight sparrow
#

rearrange scripts table

wild comet
#

i dont really understand how im supposed to do the table

chrome echo
tight sparrow
#

rearrange it

#

omg

#

👋bye

wild comet
#

im sorry bro

main ruin
tight sparrow
#

no you do not

#

key being the name of a script

chrome echo
tight sparrow
#

value being the module return value

#

thats the entire point of a map

main ruin
wild comet
#

so how would i rearrange it? idk what the variables are supposed to be listed like

#

like the values in the table

#

how would i rearrange this? im not sure what the values are supposed to be

local scripts = {
    "scription",
    "las_script",
    "module_scription",
    "record_scripta",
    "local_scription",
    "los_script_combination",
    "la_scripta",
    "remote_eventa",
    "las_scriptiosos",
    "le_click_detector"
}```
#

ok so wait

#

would i do this?

main ruin
#

Let him cook

main ruin
#

It's not that hard evilcat

wild comet
#
local scripts = {
    [1] = "scription",
    [2] = "las_script",
    [3] = "module_scription",
    [4] = "record_scripta",
    [5] = "local_scription",
    [6] = "los_script_combination",
    [7] = "la_scripta",
    [8] = "remote_eventa",
    [9] = "las_scriptiosos",
    [10] ="le_click_detector"
}

for k, v in scripts do
    print(`{v}`)
end```
dusky swallowBOT
#

studio** You are now Level 6! **studio

wild comet
#

would i do that?

chrome echo
#

are we deadass

dusky swallowBOT
#

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

wild comet
main ruin
#

No

#

It's beautiful

wild comet
#

does it work good?

main ruin
#

A script only a mother can love

wild comet
#

im going to test it

chrome echo
#

@dim patio

#

look at this dude

#

😂

main ruin
wild comet
#

would i just add

for k, v in scripts do
    print(`{v}`)
    if `{v}`== item then
        print("found!")
    else
        return 
    end
end```
#

??

wild comet
chrome echo
#

lets go gambling

#

aw dang it

wild comet
#

im going to test it

chrome echo
#

wait

#

thats not even gonna work

wild comet
#

why not

chrome echo
wild comet
#

i just tested it

chrome echo
#

if it works im gonna jump straight into the fiery pits of hell

wild comet
#

ok look ill show u

main ruin
chrome echo
dim patio
#

???

#

why loop through all of them

#

to check tho

#

what

chrome echo
#

we said use a map and then index it to find it

main ruin
chrome echo
#

😔

dim patio
#

yeah just use a map

chrome echo
dim patio
#

idk why ur looping through it everytime

chrome echo
#

because its gonna insta return if it doesnt match on first check

wild comet
#

it not work

#

:(

main ruin
#

Then bro proceeded to number the keys by thier default number

wild comet
#

OMG I MADE IT WORK
:D

chrome echo
wild comet
#

wait lemme convert that to mp4

main ruin
#

Crazy

wild comet
main ruin
#

No

wild comet
#

here

main ruin
#

Did you try to /summon a different item?

wild comet
#

yeah

main ruin
#

What in the hakari bullshit

wild comet
#

how do i get the value of it

#

nvm i got it lets goo

#

tysm

tight sparrow
#
local scripts = {
    ["scription"] = require(scription),
    ["las_script"] = require(las_script),
    ["module_scription"] = require(module_scription),
    ["record_scripta"] = require(record_scripta),
    ["local_scription"] = require(local_scription),
    ["los_script_combination"] = require(los_script_combination),
    ["la_scripta"] = require(la_scripta),
    ["remote_eventa"] = require(remote_eventa),
    ["las_scriptiosos"] = require(las_scriptiosos),
    ["le_click_detector"] = require(le_click_detector)
}

function Request(inp)
  local code = scripts[inp.lower()]
  code()
end
wild comet
#

btw im making a game where its called steal a script so u steal scripts of other people that do certain things

tight sparrow
#

you'll prob need loadstring permissions for that

#

beware..

wild comet
#

how do i get those

tight sparrow
#

its a property in

#

serverscriptservice

#

allows you to execute code from

#

string

wild comet
#

i see

#

do i just tick it?

tight sparrow
#

yes if u want to run the code

wild comet
#

ok tysm

chrome echo
#

should add a check for if the thing actually exists

tight sparrow
#

why

chrome echo
#

and you get error

tight sparrow
#

yes you get a useful error

chrome echo
tight sparrow
#

it is

#

if it aint there (it errors the thread)

chrome echo
#
  • if youre a dev who can see said error trying to add something to it in the future the attempt to call nil error wont do anything
#

even if you were to just return trying to add something new, any error from the actual function is much more useful (or even the lack of error, is still useful)

tight sparrow
#

xpcall(callscript,function() warn("Something went wrong ".. debug.traceback()) end)

chrome echo
tight sparrow
#

does not matter

#

what

#

you can display the error message with a ui event too

chrome echo
tight sparrow
#

it is error handling 101

#

using an if statement would only catch the error ‘it does not exist’

#

using xpcall would catch any errors within the code aswell

chrome echo
#

theres no point in calling a function that doesnt exist

dusky swallowBOT
#

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

tight sparrow
#

stop larping

chrome echo
#

?

tight sparrow
#

dont be idiot

chrome echo
#

im saying theres no point to even trying to call it

#

since

#

guess what

#

theres nothing to call

tight sparrow
#

a function that doesnt exist will not be called it’ll error directly

deep agate
#

oh wait

#

hold on

chrome echo
#

so why are you trying to try to call it?? do you like seeing errors

deep agate
#

am i tripping

#

its 5 am i ahvent slept

tight sparrow
#

the callback in xpcall would be the plr.Chatted function

cunning heath
#

if ur just starting avoid pcall imo

cunning heath
#

just gonna hide errors and confuse you

tight sparrow
cunning heath
#

99% of errors can be avoided using conditionals

tight sparrow
#

that if its not a true functions

delicate bane
chrome echo
tight sparrow
#

using xpcall youre catching any errors within the code itself

tight sparrow
#

xpcall allows you to handle errors however you want

#

u can use it to send it to the client for a ui message

chrome echo
#

I know how xpcall works

cunning heath
tight sparrow
#

no u dont

#

😭

chrome echo
#

yes I do ?

tight sparrow
#

you wouldnt be arguing against xpcall if youd know

#

what it does

#

and why it does it

delicate bane
deep agate
#

would be great

cunning heath
tight sparrow
cunning heath
#

ive never used xpcall once

tight sparrow
#

its used for custom error handling

cunning heath
#

ik, that isnt useful to me

#

i just use if statements

tight sparrow
#

if youre allowing users to post and run code

#

it’d be the most useful thing ever

cunning heath
#

its just syntactic sugar to persist local variables instead of using upvalues

#

u can do the same stuff using pcall

tight sparrow
#

does pcall yield

chrome echo
cunning heath
#

???

delicate bane
cunning heath
#

skidsplosion happening in here

tight sparrow
#

xpcall is luau

#

2nd param is a function thats used for resolving that error

#

common usage is promise handling

cunning heath
#

huh

tight sparrow
#

pcall is the same thing but you avoid ass code looks

cunning heath
#

do you error your promises to cancel them lol

tight sparrow
#

local succ,result = pcall(function() return 5 end)
if succ then
return result
else
— errorhandling
end

#

this is the same as

cunning heath
#

I use task,cancel

tight sparrow
#

return xpcall(function() return 5 end, function(err) print("Errored") error(err,2) end)

#

2nd param is just error handling

delicate bane
#

since when was ui like this

tight sparrow
tight sparrow
#

its a bit better ig

cunning heath
#

i only use it to guarantee data on player added

tight sparrow
#

old ui was buggy as hell

#

Unlike pcall(), the err function preserves the stack trace of function f, which can be inspected using debug.info() or debug.traceback().

cunning heath
#

if you need the stacktrace outside of the pcall ur design is silly goofy

#

/s that is actually a decent use tho

#

for logging

tight sparrow
#

in the end i think its better in all cases to use pcall or xpcall to handle errors in unreliable code than to only handle the error if its ‘not found’

deep agate
#

Isnt this just up to the OP on which one works and/or doesnt work since we dont know exactly his framework on it or am i just really confused here

delicate bane
#

i saw a cool method to get direct metamethod references for roblox objects ```lua
local _, Destroy = xpcall(function()game.Destroy()end, function()
return debug.info(2, "f") -- should return Destroy method?
end)

deep agate
#

So what was the point in arguing???

tight sparrow
#

thats cus it returns the ‘f’

deep agate
#

just asking cause like

#

my brain is fucking fried

chrome echo
tight sparrow
cunning heath
#

tell me ur additions to this log