AI-Powered Code Help

Yea… but sometimes its uhh… weird.

--make a cosine projectile that hits a player
--make a variable for the player
local plr = game.Players.LocalPlayer
--make a variable for the mouse
local m = plr:GetMouse()
--make a function that makes the projectile
function makeProjectile()
	--create a part and set it's properties
	local projectile = Instance.new("Part")
	projectile.Parent = workspace
	projectile.Size = Vector3.new(1,1,1)
	projectile.Position = plr.Character.HumanoidRootPart.Position + Vector3.new(0,5,0)
	--create a mesh and set it's properties
	local mesh = Instance.new("SpecialMesh")
	mesh.Parent = projectile
	mesh.MeshType = Enum.MeshType.Sphere
	
	--set up some variables to use later on in the script (these are local variables so they can't be accessed outside of this function)
	local velocityVector --this is where we will store our velocity vector (the direction and speed at which our projectile moves)
	local gravityVector --this is where we will store our gravity vector (the direction and speed at which our projectile falls down due to gravity)
	
	--connect an event that runs every frame while the player holds down their left mouse button. This event will run 60 times per second.
	m.InputChanged:Connect(function(inputObject) 
		if inputObject.UserInputState == Enum.UserInputState.Begin then --if the user starts holding down their left mouse button...
			if inputObject.KeyCode == Enum.KeyCode.MouseButton1 then --...check if they are pressing their left mouse button...
				while inputObject.UserInputState ~= Enum.UserInputState.End do --...while they are still holding down their left mouse button...
					wait() --wait until next frame before running code again. This way we don't have to wait 1/60th of a second between each line of code.
					inputObject.Changed:Wait() --wait until something changes about this Input Object before continuing with code. This way we don't have to check if UserInputState has changed every single frame.
					
					velocityVector = CFrame.lookAt(projectile.Position,m.Hit.p).lookVector * 100 --calculate what direction and how fast our projectile should move based on where your cursor is pointing when you click your left mouse button.
					print(velocityVector) 
					
					repeat wait() until not pcall(function() return m.Target end) or m.Target.Name ~= "Terrain" or m

it didnt even finish the code.

So for me to clear my confusion, once I write my prompt, do I press enter?

Yea, and then press tab once the code generates

Alright! Thank you so much for the help!

I’m so sorry to be a bother, but it still isn’t generating.

Restart it again, make sure the game you are using it in is published and http requests enabled.

Does it generate instantly? Or do I wait a little bit?

It might take like 2 or 4 seconds, max 10 seconds…

Alright, So I finished my prompt (this is my prompt that I used for example) -- Make a part that explodes when a player touches it and then I press enter then tab? I also have print('Hello World!") before the prompt. So does that affect anything or no?

It doesnt affect anything really… just wait until the code generates and then press tab

Yeah I’ve been waiting for 10 minutes now and it hasn’t generated anything. I also didn’t get the ToS for the Generative Code

Just disable it, and then save, and then re-enable it and restart studio.

Alright, I’ll try this, if not then I’ll just use GitHub Copilot

1 Like

It doesn’t seem to be working for me currently but I did get a screenshot of it in action yesterday:
The generated bit starts at -- Game.


It took at most a few seconds to fill in but it did generate correct code (apart from the extra end) in that instance at least.

Yeah I give up on this thing. Roblox should’ve made this easier to access, or leave instructions on how to use it. I’ll just use GitHub Copilot

Why not just use ChatGPT? It’s free and doesn’t require you to load into a seperate IDE to use it.

I think what you need to do is make the prompt, press enter, let the AI generate the code and then press tab, as you would do with github copilot, it is still an early beta for this feature and for now copilot is a better tool if you are able to access it anyway

Because they are trying to use a Roblox Beta Feature, not an external tool. They aren’t asking for help with ChatGPT, they just want to figure out how to use the now built-in tool in Roblox Studio

1 Like

First of all, ChatGPT is an out dated AI model that doesn’t really know the new API like overlap queries and raycast, and then you have that it takes an account in order to use it which many people might not be willing to create just for making kind of bad code for their roblox games.

1 Like

If you create a new script, does a yellow bar appear at the top?

If so, you need to click the link part of it, which will open up a box for you to press. (Box didnt show up on the video)