Trying to create a couple of parts to move when I use my move keys, heres the scipt
local UIS = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
local player = game.Players.LocalPlayer
local function getCity()
return workspace.Cities:FindFirstChild(player.Name .. "_City")
end
local speed = 40
local turnSpeed = 1.2
local forward = 0
local turn = 0
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W then forward = 1 end
if input.KeyCode == Enum.KeyCode.S then forward = -1 end
if input.KeyCode == Enum.KeyCode.A then turn = -1 end
if input.KeyCode == Enum.KeyCode.D then turn = 1 end
end)
UIS.InputEnded:Connect(function(input)
if input.KeyCode == Enum.KeyCode.W or input.KeyCode == Enum.KeyCode.S then forward = 0 end
if input.KeyCode == Enum.KeyCode.A or input.KeyCode == Enum.KeyCode.D then turn = 0 end
end)
RunService.RenderStepped:Connect(function(dt)
local city = getCity()
if not city then return end
local core = city.PrimaryPart
if not core then return end
local move = core.CFrame.LookVector * forward * speed * dt
local rotate = CFrame.Angles(0, turn * turnSpeed * dt, 0)
core.CFrame = core.CFrame * rotate + move
end)
** You are now Level 7! **