Thoughts on using AI for scripting

Thought I would express how AI has helped me improve my rLUA coding skills as well as formatting. Completely learned how to use modules rather than using my previous strategies of just hardwiring tables/variables in multiple different scripts. Has helped me so much.

Not sure if this has been asked here or of it’s looked down upon but how do you guys/scripters feel about using AI such as gpt or other stuff to help you code? Personally, I’ve found it to be insanely helpful, especially when you don’t just copy the code from it but try to read and understand what the AI is fixing/doing for you.

I definitely get a lot of errors sometimes in scripts and AI is incredibly helpful finding these errors and solving them and then explaining what they did instead of just spoonfeeding me the code which has definitely improved my skills by a lot.

I try not to use it too much but for small errors or typo’s I can’t seem to find, it does a really good job. I also use it to format my code when it’s really messy.

I find AI extremely helpful, especially when you’re trying to understand how and what its doing for you instead of copy and pasting.

My overall perspective of using AI is highly favorable of it, it doesn’t always fix/solve your issues first try but through trial and error it tries to adapt and learn through multiple tries and tests. It sometimes takes up to an hour and many tests/different versions of code but eventually you will either completely solve the issue or the AI will make a placeholder for you and generate many different versions that you can use as a placeholder/idea.

Lastly, the most impressive thing about AI is that you can force it to adapt and give it prompts such as “This current logic/function isn’t working correctly, lets try a different approach such as using “runservice” instead of a wait loop” etc, and you can get the AI to try something completely different until you end up finding the solution, or atleast generating a different idea to use.

Last thing, one of the most impressive things about AI, chatgpt specifically(from experience) is that if the logic of your script isn’t working, you can research different types of functions online, such as devforum, you can copy the post or piece of text that explains how a function works, and you can tell chatgpt to use that information as a reference and build the code using that 3rd party information to learn and innovate from. For example if you’re telling chatgpt to make a code that converts a numbervalue to a text, chatgpt keeps trying the same logic over and over, so I go to roblox script documentation and find the tostring function, I copy the documents text explaining how tostring works, and tell gpt to use it to try a new approach, it learns from the information and uses tostring to convert number to text and code ends up working. I couldn’t think of a good example so this is very random but thats just an idea/example of how AI can use information to learn and innovate previous versions instead of repeating the same logic/information.

Don’t mean to ramble on but I have improved my scripting by a large margin ever since AI was released, I read and understand what the AI created/fixed and then use the code to replace my previous code or use as a reference to improve my previous code.

Apologies for the rant but just wanted to express how AI has personally improved my skills.

Just curious what you guys think of it and how you use it. :grinning:

TL;DR: How do you use/benefit from AI when writing code, or what are your overall thoughts on it.

Keypoints from personal experience

  1. AI can adapt and learn from information given to it
  2. AI can explain what it created/fixed for you instead of just spoonfeeding you the solution
  3. AI can format messy code as well as add in text statements to explain code(Eg. --This part of the script controls the cooldown settings)
  4. AI can spot typo’s or errors insanely quickly, useful for brainfog or just having a slow moment
  5. You can empower Ai to try different approaches rather than trying the same logic over and over
  6. AI will continuously try to improve/fix code through trial and error
  7. Lmk if I’m missing anything
1 Like

I agree, the Assistant in Studio has helped me many times while trying to figure out even simple things. If I’m having trouble with a certain section of my code I can just ask the assistant to give me an example of just what that section of code should look like. For a recent example, learning how to write the lines of code to tween a weld instead of CFraming an Anchored item so I could use it on something that wasn’t stationary. I just asked it to code how to tween the C0 of a weld, not specific to the rest of my script. It told me how the code needed to be written so I could add it to the section of code I was working on.

2 Likes
Summary

As in “Assistant” is there an AI helper in studio? I’ve never heard of that.I agree, it’s very helpful for trying to create a placeholder script/ generating an idea of what to start out with.

But for me sometimes some scripts don’t work and I don’t know why since I tried giving it a lot of detail and discussing the issue but its just wrong. Any solutions to fix this?

To find Assistant you need to go to FILE in ROBLOX Studio then look for Beta Features then click it then scroll down till you see Assistance and click the blue box to get it active.

That’s pretty neat actually, I’ll definitely be using this and see how it compares to chatgpt. Since it’s fully made for rLUA I think? I’m guessing it should have a more in depth understanding unlike gpt which has to learn sometimes since it’s not aware of deprecated functions and other things like that.

Prompt and Output

AI code used in game:

Worked no problems, instant output and even made it relatively simple though it didn’t explain what it did but I’m sure I can ask it to. Overall AI is pretty decent.

1 Like

Do you have any solutions how I can get it to stop asking me incorrect scripts since this occurs to me and I am giving it well detailed info but it just gives me wrong scripts most of the time?

Honestly man it’s all about the prompt/information you give it, I’ve found that especially with ChatGPt you have to be extremely detailed and specific otherwise it will just output nonsense sometimes or stuff that isn’t relevant. I’m gonna put a test comparing chatgpt vs Assistant Ai here in a minute and you should take a look at the prompts and get an idea of what you have to feed it/tell it. Sometimes you have to make a couple paragraphs explaining what you’re doing/want it to do and even give it a script to rewrite/innovate a little bit.

Stay tuned for the test in a couple mins, pretty interesting in my opinion

That’s pretty neat actually, I’ll definitely be using this and see how it compares to chatgpt using some more complex stuff. Since it’s fully made for rLUA/studio Iguess? I’m guessing it should have a more in depth understanding of all of the services and functions of studio/rLUA,etc unlike gpt which has to learn sometimes since it’s not aware fully the services and studio setup as well sometimes being unaware of deprecated functions and other things like that which can be solved easily but takes some more trial and error and more information/prompts. :grinning:


ChatGPT vs Studio AI Assistant test below :robot: vs :roblox_light:

(First time using Studio Assistant by the way, so should be interesting)

If anyone wants to see ChatGPT vs Studio Assistant I was bored and ran a simple test below :arrow_down: I went a little overboard on this with all the info but it was pretty interesting and fun seeing the difference in the two programs. Overall I’d say it was definitely a close “match” but Studio AI assistant got the win due to it being much more simplified and a lot easier to understand, especially for someone just getting started with rLUA which is definitely helpful. ChatGPT got the job done though as well, just with more logic which is perfectly fine :white_check_mark: :robot:

  • What am I testing exactly?

Testing Ai Assistance vs Chatgpt with simple prompt. Making it create a code that prints every child inside of replicated storage and ordering them based on their name(first letter of the child’s name) alphebatical order, and labeling them in number order based on that alphabetical order the name is .

The prompt given to both ChatGPT and AI Assistant are exactly alike except I included the language I want the code to be written in(rLUA) just to make sure it’s familiar with what we’re doing.

(Example: If there are 2 children in ReplicatedStorage with the following names, Automobile, and Batscripthandler, The scripts written by the AI’s should order the Automobile as #1, and Batscripthandler as #2 because A comes first in the alphabet. Very simple, just seeing what their logic is like)

Based on those 2 example children, using them as an example. Both, GPT, and studio assistant should print in the dev console

--Example of what script should look like
"#1: Automobile"
"#2: Batscripthandle"
"#3: C" -- etc
"#4: G" -- if there is no D,E,F"

Very simple, just wanted to see how long it takes for them to create the script whether it takes a couple different prompts and tries or first try, do they follow the same logic,functions(such as table

AI Assistance Test

AI Assistant Prompt given as well as output returned from AI

Ai Assistant code tested in game

Works perfectly, short and simple, and got it first try very quickly.


ChatGPT Test

Prompt Given to GPT, same as Assistant prompt, just told it what language/

ChatGPT output from prompt given

ChatGPT code tested in game(studio)

image

Just thought it’d be interesting to compare GPT to Studio AI Assistant, both use the same logic pretty much just different formatting and different incorporations of the logic. GPT has more lines and is a little more complex/detailed than the Studio AI assistant which is simple and gets the job done. Both GPT and AI Assistant’s codes worked perfectly and had the exact same outcome/result and completed the task.

Results of simple test regarding ChatGPT and Studio AI Assistant completing task with same prompt:

You can notice the difference in the way GPT works and AI Assistant, from my perspective it tries to make everything detailed and somewhat complex unless you ask it to simplify it which isn’t a bad thing. ChatGPT is very helpful because it likes to use functions frequently in its code which helps and makes it easier to simplify some of the logic instead of hardcoding everything.


Prompts Given below: Only difference is I defined/wrote what language the code should be written in for chatgpt just to make sure it knows its specifically for rLUA/Roblox. Resulted in same outcome as seen in the tests.

Studio Assistant Prompt

*** make a script to look through replicatedstorage and print every single item in it and order them by alphabetical order. Use numbers like 1,2,3 to list them.

ChatGPt Prompt

make a script to look through replicatedstorage and print every single item in it and order them by alphabetical order. Use numbers like 1,2,3 to list them.(roblox script rlua)

AI Assistant code for anyone interested:

 -- Script to print every item in ReplicatedStorage in alphabetical order

local replicatedStorage = game:GetService("ReplicatedStorage")

-- Get all the children of ReplicatedStorage
local children = replicatedStorage:GetChildren()

-- Sort the children by name
table.sort(children, function(a, b)
    return a.Name < b.Name
end)

-- Print the sorted children
for i, child in ipairs(children) do
    print(i..". "..child.Name)
end

ChatGPt Code for anyone interested:

-- Function to sort the table alphabetically
local function sortAlphabetically(a, b)
    return tostring(a) < tostring(b)
end

-- Get ReplicatedStorage
local replicatedStorage = game:GetService("ReplicatedStorage")

-- Get all children of ReplicatedStorage
local children = replicatedStorage:GetChildren()

-- Create a table to store the names
local names = {}

-- Populate the table with the names of the children
for index, child in ipairs(children) do
    table.insert(names, child.Name)
end

-- Sort the table alphabetically
table.sort(names, sortAlphabetically)

-- Print the sorted names with numbered ordering
for index, name in ipairs(names) do
    print(index .. ": " .. name)
end

But yesterday when I was making a project on a cart ride I asked for a script how to make a part move like a cart ride but it was just giving me the incorrect scripts.

You gotta be very specific, like for example you would have to say

AI tries to learn and adapt from what you tell it so you sometimes have to go on for a while to try and get it to understand what you want from it, yk.

I find it very effective to first start out and make the script, just the base of it like defining your Cart model and your parts inside the cart that you want to move or etc,

Such as "Heres my cart model and defined parts, make the carts wheels move forwards when I click this button, or slow down when I click the other button.

local Cart = game.Workspace.Cart
local Wheel = Cart.Wheel1
local Wheel2 = Cart.Wheel2

"

Now that it knows the model and parts, it can start to script the cart based on the information you gave it such as the wheels.

Prompt to give AI example:
"I'm making a cart ride game, I need to make a part that moves forward when you click this button or slow it down when you click that button, make sure you make it simple and efficient"

Lemme try this and see if it works. Give me a second

1 Like

Just start off simple first, find out exactly what you want the cart to do and how you want it to work, such as using remotes or just using 1 script inside the cart. Then make sure you define all of the stuff the AI is going to need such as this:

local Cart = game.Workspace.Cart
local Wheel = Cart.Wheel1
local Wheel2 = Cart.Wheel2

local Gobutton = Cart.Go
local StopButton = Cart.Stop

Prompt to say to the AI
"Use the variables/parts above I gave you and make a cart that moves forward when you click go, and stops when you click stop"

Now it knows the buttons to script, and the wheels it needs to move,etc. So you can try and build off of that and test it a little bit, isn’t always instant. Gotta use your knowledge too.

I have a question with my cart, For some reason the parts keep falling off when they are anchored/placed as a model I dont know why but this is affecting my cart do you know why?

If you wanna add me to the game via team create I can try and help out a bit and assist you a little. No worries if not.

Also it isnt a real game its just a fun project am trying to do also sure I can add you!

1 Like

You need to friend me to be able to edit.

Move to devforum messages, I’ll contact you through there.