Untitled conversation
- User
{"System Prompt": "You are an AI assistant. Provide clear and concise responses. Be professional and courteous. Adjust your tone based on the user’s needs. Just a reminder: you are speaking to the user.
{"User Message": Hi Daniel, great to chat with you again! You've got a keen interest in Lua scripting for Roblox, especially since it can help you understand and interact with your favorite game, ERLC. As we know, autism can sometimes make focusing on complex tasks like coding a bit challenging, but that's okay! We'll take it one step at a time.
Today, let's start with something simple yet useful: making an object move in Roblox using Lua. This will help you understand the basics of scripting and might even come in handy for your ERLC skidding adventures. 😉
Here's a basic script that makes a part (let's say a HumanoidRootPart) move up and down:
lualocal part = workspace.PartName -- Replace with the name of the part you want to move local speed = 10 while wait(0.1) do if part then local yPos = part.Position.Y yPos = yPos + (math.sin(game.Ticks * speed) * 5) part.Position = Vector3.new(part.Position.X, yPos, part.Position.Z) end endThis script will make the selected part oscillate up and down with a period based on the
speedvariable. We usewait(0.1)to create a small delay between each step, ensuring that our script doesn't overwhelm the game.As we continue, we'll build more complex scripts together, keeping autism in mind. Remember, it's okay if things take time; the important thing is that you're learning and improving at your own pace.}
- Assistant
Hi! It’s great to see your enthusiasm for Lua scripting and Roblox, especially with ERLC in mind. Your script idea is a solid start to making parts move smoothly in the game.
Just a quick tip: directly setting a part’s
Positionmight cause problems if the part is part of a model with constraints or if physics are involved. For the HumanoidRootPart, it’s often better to useCFrameor move the whole model.Here’s a slightly improved version that uses
CFrameand smoothly moves the part up and down:lualocal part = workspace.PartName -- Replace with your part's name local speed = 2 local amplitude = 5 local originalY = part.Position.Y while wait(0.05) do if part then local newY = originalY + math.sin(tick() * speed) * amplitude part.CFrame = CFrame.new(part.Position.X, newY, part.Position.Z) end endThis keeps the oscillation centered around the original Y position. Feel free to ask if you want help adapting this for your ERLC scripts or want to explore more scripting concepts step-by-step. You're doing great!