Help to fix my car

so its very explainable what i want:

local Players = game:GetService("Players")
local ServerScriptService = game:GetService("ServerScriptService")

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local rootPart = character:WaitForChild("HumanoidRootPart")

	-- Find the DogeStud mesh in Workspace
	local dogeStud = workspace:FindFirstChild("DogeStud")
	if not dogeStud then
		return
	end

	-- Create a BodyVelocity object to control the DogeStud
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = Vector3.new(0, 0, 0)
	bodyVelocity.MaxForce = Vector3.new(0, math.huge, 0)
	bodyVelocity.P = 10000
	bodyVelocity.Parent = dogeStud

	-- Function to handle keyboard input
	local function handleKeyPress(input)
		if input.KeyCode == Enum.KeyCode.W then
			bodyVelocity.Velocity = rootPart.CFrame.LookVector * 50
		elseif input.KeyCode == Enum.KeyCode.A then
			bodyVelocity.Velocity = -rootPart.CFrame.RightVector * 50
		elseif input.KeyCode == Enum.KeyCode.S then
			bodyVelocity.Velocity = -rootPart.CFrame.LookVector * 50
		elseif input.KeyCode == Enum.KeyCode.D then
			bodyVelocity.Velocity = rootPart.CFrame.RightVector * 50
		end
	end

	-- Connect the keyboard input to the handleKeyPress function
	game:GetService("UserInputService").InputBegan:Connect(handleKeyPress)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

it just doesn’t move the script is in serverscriptservice

You realize UserInputService doesn’t work in scripts right

so now i have a serverscriptservice script:

local Players = game:GetService("Players")

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local rootPart = character:WaitForChild("HumanoidRootPart")

	-- Find the DogeStud mesh in Workspace
	local dogeStud = workspace:FindFirstChild("DogeStud")
	if not dogeStud then
		return
	end

	-- Create a BodyVelocity object to control the DogeStud
	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = Vector3.new(0, 0, 0)
	bodyVelocity.MaxForce = Vector3.new(0, math.huge, 0)
	bodyVelocity.P = 10000
	bodyVelocity.Parent = dogeStud

	-- Function to handle keyboard input from the client
	local function handleKeyPress(player, keyCode)
		if keyCode == Enum.KeyCode.W then
			bodyVelocity.Velocity = rootPart.CFrame.LookVector * 50
		elseif keyCode == Enum.KeyCode.A then
			bodyVelocity.Velocity = -rootPart.CFrame.RightVector * 50
		elseif keyCode == Enum.KeyCode.S then
			bodyVelocity.Velocity = -rootPart.CFrame.LookVector * 50
		elseif keyCode == Enum.KeyCode.D then
			bodyVelocity.Velocity = rootPart.CFrame.RightVector * 50
		end
	end

	-- Listen for the client's keyboard input
	local function onKeyPress(player, keyCode)
		handleKeyPress(player, keyCode)
	end

	-- Connect the client's keyboard input to the server's handleKeyPress function
	humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
		humanoid.WalkSpeed = 0
	end)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

and a localscript in starterplayerscripts:

local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:WaitForChild("KeyPressEvent")

-- Function to send the key press event to the server
local function sendKeyPress(keyCode)
	RemoteEvent:FireServer(keyCode)
end

-- Listen for the client's keyboard input
UserInputService.InputBegan:Connect(function(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		sendKeyPress(input.KeyCode)
	end
end)

remote event is called KeyPressEvent, and it still dosent work with no output

local carPart = script.Parent -- Reference to the car part with the ClickDetector
local clickDetector = carPart:WaitForChild("ClickDetector") -- Make sure to name your ClickDetector "ClickDetector"

-- Function to handle car repair
local function repairCar()
    -- Add your repair logic here
    print("Car is now fixed!")

    -- You can reset the car's position or change its appearance as needed
    carPart.CFrame = CFrame.new(Vector3.new(0, 5, 0)) -- Example: Reset position to (0, 5, 0)
end

-- Connect the repair function to the ClickDetector's MouseClick event
clickDetector.MouseClick:Connect(repairCar)

Replace “ClickDetector” with the actual name of your ClickDetector.

Adjust the repairCar function to include the specific logic needed for fixing your car. This could involve resetting the car’s position, repairing its appearance, or any other actions related to the repair process.

Make sure to test and customize the script based on your game’s requirements.

It seems like you took the title too literally lol. OP is having an issue moving the car and not what you gave.

1 Like

Well that’s yes I help you I say so don’t wonder at me about that

@DogeTheStudio you aren’t connecting any OnServerEvents in your script.

No you are about something that is better speak English

Probably be better off doing the control the car part in a client script.

You are alright im that script something get help you and something see be

Even if so, it is still quite rude saying that to someone. Instead of saying like that we should help said user to know english better and stuff.

Alright you are said about version man guy but tell him nice you about

Yes i use GPT, thats how i learn

Great way to get totally mislead. GTP is junk.

I rewrote your code (cleaned it up a bit) but I didn’t test it …
Let’s hope you got the logic right …

local Players = game:GetService("Players")

local function onCharacterAdded(character)
	local humanoid = character:WaitForChild("Humanoid")
	local rootPart = character:WaitForChild("HumanoidRootPart")
	local dogeStud = workspace:FindFirstChild("DogeStud")

	if not dogeStud then return end

	local bodyVelocity = Instance.new("BodyVelocity")
	bodyVelocity.Velocity = Vector3.new(0, 0, 0)
	bodyVelocity.MaxForce = Vector3.new(0, math.huge, 0)
	bodyVelocity.P = 10000
	bodyVelocity.Parent = dogeStud

	local function handleKeyPress(keyCode)
		if keyCode == Enum.KeyCode.W then
			bodyVelocity.Velocity = rootPart.CFrame.LookVector * 50
		elseif keyCode == Enum.KeyCode.A then
			bodyVelocity.Velocity = -rootPart.CFrame.RightVector * 50
		elseif keyCode == Enum.KeyCode.S then
			bodyVelocity.Velocity = -rootPart.CFrame.LookVector * 50
		elseif keyCode == Enum.KeyCode.D then
			bodyVelocity.Velocity = rootPart.CFrame.RightVector * 50
		end
	end

	local function onKeyPress(_, keyCode)
		handleKeyPress(keyCode)
	end

	humanoid:GetPropertyChangedSignal("WalkSpeed"):Connect(function()
		humanoid.WalkSpeed = 0
	end)
end

local function onPlayerAdded(player)
	player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)