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
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.
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)