Deadwoodx
(Deadwoodx)
May 23, 2021, 2:38pm
#1
My car is not moving, and the topic is the question.
The script:
local canwork = true
local uis = game:GetService("UserInputService")
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
canwork = true
print("Car works now")
end)
uis.InputBegan:Connect(function(key,ischatting)
if canwork == true then
local success,errormessage = pcall(function()
print("Car starting to move")
if canwork == true and key.KeyCode == Enum.KeyCode.W and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.LookVector*15
wait(1)
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.A and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.RightVector*-15
wait(1)
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.S and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.RightVector*15
wait(1)
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.D and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.LookVector*-15
wait(1)
canwork = true
end
end)
if success then
print("Car Moved")
else
print(errormessage)
end
end
end)
Deadwoodx
(Deadwoodx)
May 23, 2021, 2:48pm
#2
Uh can anyone tell me how to fix it please?
Why are you using a local script for your car only the one person can see it move that is why it is not moving you are calling it through a local script
Deadwoodx
(Deadwoodx)
May 23, 2021, 3:05pm
#4
Its my first time making a car, i am first trying to use a local script then go to complex one of car
I think it’s because he needs the UserInputService
Deadwoodx
(Deadwoodx)
May 23, 2021, 3:05pm
#6
yes and i am new in making a car to
This is in a localscript or a script?
Deadwoodx
(Deadwoodx)
May 23, 2021, 3:08pm
#8
local script its sometimes working and sometimes not working, and even if it works its going front and back only, its not turning left and right maybe wheels wont turn
Deadwoodx
(Deadwoodx)
May 23, 2021, 3:42pm
#11
Ok I fix it but why is it not turning correctly.
Here is the script:
local canwork = false
local uis = game:GetService("UserInputService")
local rotation = nil
game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(function()
canwork = true
print("Car works now")
end)
uis.InputBegan:Connect(function(key,ischatting)
if canwork == true then
local success,errormessage = pcall(function()
print("Car starting to move")
if canwork == true and key.KeyCode == Enum.KeyCode.W and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.LookVector*15
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.A and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyGyro.CFrame = game.Workspace.CarBase.CFrame * CFrame.lookAt(game.Workspace.CarBase.Position,game.Workspace.CarBase.Position + game.Workspace.CarBase.CFrame.RightVector*20)
rotation = game.Workspace.CarBase.CFrame * CFrame.lookAt(game.Workspace.CarBase.Position,game.Workspace.CarBase.Position + game.Workspace.CarBase.CFrame.RightVector*20)
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.RightVector*-15
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.S and ischatting ~= true then
canwork = false
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.LookVector*-15
canwork = true
elseif canwork == true and key.KeyCode == Enum.KeyCode.D and ischatting ~= true then
canwork = false
rotation = game.Workspace.CarBase.CFrame * CFrame.lookAt(game.Workspace.CarBase.Position,game.Workspace.CarBase.Position + game.Workspace.CarBase.CFrame.RightVector*-20)
game.Workspace.CarBase.BodyGyro.CFrame = game.Workspace.CarBase.CFrame * CFrame.lookAt(game.Workspace.CarBase.Position,game.Workspace.CarBase.Position + game.Workspace.CarBase.CFrame.RightVector*-20)
game.Workspace.CarBase.BodyPosition.Position = game.Workspace.CarBase.BodyPosition.Position + game.Workspace.CarBase.CFrame.RightVector*15
canwork = true
end
end)
if success then
print("Car Moved")
else
print(errormessage)
end
end
end)
while wait(0.5) do
if canwork == true and rotation ~= nil then
game.Workspace.CarBase.BodyGyro.CFrame = rotation
end
end
try checking this car maybe?
How to Rig a Car
[lowpolycar_thumbnail]
Rigging a car in Roblox can be hard. Scripting it can be harder. In this four-part series, I walk through the basics of rigging a 3D-modeled car and some basic scripting!
Pick up the car model first!
Part 1 - Setup
Export your car and put it together in Studio.
Part 2 - Rigging the Constraints
Set up all the various attachments and constraints.
Part 3 - Server Scripting
Write the server-side script to handle the c…
If the car is handled on the server-side, you should change the NetworkOwnership to be the player when you call the FireClient()
function, otherwise handling it on the server can result in some wonky & odd effects
It’s either that or BodyPositions
handled on the server-side work funny
Deadwoodx
(Deadwoodx)
May 24, 2021, 9:40am
#14
the car is working but not turning left and right correctly