Lua not working

Muffin kid from Brazil

Brawl Stars player,not always up to play
I tried to do a lua to make Sonic slide when pressing C2

addHook("ThinkFrame", function()
local player = "sonic"
if and and not player.invincible then
if player.cmd.buttons & BT_CUSTOM2 > 0 then
if not then
if ~= S_PLAY_DEAD then = S_PLAY_STND
end = true
else = false

But it doenst work
And i get no errors when loading it in game
You tried to have chatGPT write this? I don't know why you'd think SRB2 would know you're referring to a player with a "sonic' string.

player.invincible is not a vanilla variable, and shouldn't be relevant to your sliding ability. Only an AI would make those mistakes.

addHook("PlayerThink", function(player)
if (player.cmd.buttons & BT_CUSTOM2)
if not
end = true
print("This is where I'd slide if I had code defining what sliding was! But hey, I can confirm is true!")
elseif = false
print("This is where I'd stop sliding! I can confirm has been set from true to false now!")

First, use a PlayerThink hook, that way you already have "player" defined by default. Then, forget about player.invincible entirely. Now it'll actually affect the player, but the behavior itself still isn't programmed, you only made a way to toggle "".

It's not "wrong" to use AI. Most of the time, AI can write properly sorted Lua code that won't error. But doesn't mean the code will accomplish anything. Because SRB2 doesn't know to make Sonic backflip over Eggman's head and snap his neck just because you gave him So if you're using an AI as a base, verify EVERYTHING it writes and what actually exists, because AI has extremely limited knowledge on SRB2 specifics.

For example, you can see what variables exist by googling "SRB2 Lua Userdata". You can find out what hooks are proper to use by googling "SRB2 Lua Hooks". You can find out what states exist by looking up "SRB2 states list". You could discover SRB2's standard Lua functions googling "SRB2 lua functions". Etc!

Even if you don't know coding, if you keep looking things up and verifying what the AI writes, you can modify its nonsense into something actually usable and make something cool eventually.
Yes,i used chatgpt in the hopes of getting something that i could fix
And i have a small idea of how lua works
Then i somehow tried to fix

But thanks!
I might use the one that you made as base for making luas!
Last edited:

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)