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": Hello Daniel, let's tackle Lua scripting for ERLC together! Given your interest in game development and your experience with autism, we'll take this step-by-step to ensure it's accessible and enjoyable for you. Today, let's start with a simple task: modifying character movement.
First, locate the player script (likely named "Player" or similar) in ERLC's Workspace. This is where we'll make our changes. Here's a basic character move script using Lua:
lua-- PlayerScript local player = game.Players.LocalPlayer local char = player.Character function onKeyDown(keyCode) local cam = workspace.CurrentCamera local mouse = game.Players.LocalPlayer:GetMouse() local target = mouse.Target:FindFirstChild("Handle") if keyCode == "w" then -- Forward (W key) char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame + cam.CoordinateFrame.right * 5 elseif keyCode == "s" then -- Backward (S key) char.HumanoidRootPart.CFrame = char.HumanoidRootPart.CFrame - cam.CoordinateFrame.right * 5 end end game.Players.LocalPlayer.PlayerGui.KeyboardInput-frame.InputBegan:Connect(onKeyDown)This script will allow Daniel to move his character forward (W key) and backward (S key). The speed is set at 5 units per key press.
Daniel, as we work on this together, remember to take breaks when you need them. Autism can make focusing challenging, so let's pace ourselves. If you have any questions or need further clarification, just let me know!}
- Assistant
Hello! It’s great that you’re diving into Lua scripting for ERLC. I noticed a few areas in the example script that could be improved to make character movement work smoothly:
- Detecting keyboard input usually uses
UserInputServiceinstead of connecting directly to GUI elements. - The forward/backward movement direction should be based on the camera's look vector, not its right vector.
- Accessing
mouse.Targetmight cause errors if there’s no target under the cursor, so it’s safer to handle that.
- Detecting keyboard input usually uses