Hi there, I was making a this car game and I wanted to make the inner part of the wheels turn. But in the local script for the movement of the car (placed in StarterGui), an error occurs…
Here is the line causing the error:
Car.WheelModels.FL.Inner = Vector3.new(Car.WheelModels.FL.Inner.Orientation.X,Car.WheelModels.FL.Inner.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FL.Inner.Orientation.Z)
Full code for those who want it:
local Camera = workspace.CurrentCamera
local Car = workspace.PlayerCar
local CarDir = Car.CarDir
local CamPart = Car.CamPart
local CarSpeed = 55
local turnSpeed = 2
local Control_V = 0
function GetKey(k1,k2)
local held = 0
if k2 and game.UserInputService:IsKeyDown(Enum.KeyCode[k2]) then
held = 1
elseif game.UserInputService:IsKeyDown(Enum.KeyCode[k1]) then
held = 1
end
return held
end
game["Run Service"].RenderStepped:Connect(function(delta)
Camera.CameraType = Enum.CameraType.Scriptable
game.TweenService:Create(Camera, TweenInfo.new(0.2), {CFrame=CamPart.CFrame}):Play()
script.SetNetwork:FireServer(Car)
local Keys = {
Horizontal = GetKey("D","Right")-GetKey("A","Left"),
Vertical = GetKey("W","Up")-GetKey("S","Down")
}
Control_V += (Keys.Vertical-Control_V)/7
CarDir.AssemblyLinearVelocity += (CarDir.CFrame.LookVector*CarSpeed*Control_V-CarDir.AssemblyLinearVelocity)/10
CarDir.AssemblyAngularVelocity = Vector3.new(0,turnSpeed*-Keys.Horizontal*Control_V,0)
Car.WheelModels.FL.Inner = Vector3.new(Car.WheelModels.FL.Inner.Orientation.X,Car.WheelModels.FL.Inner.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FL.Inner.Orientation.Z)
Car.WheelModels.FL.Rim = Vector3.new(Car.WheelModels.FL.Rim.Orientation.X,Car.WheelModels.FL.Rim.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FL.Rim.Orientation.Z)
Car.WheelModels.FL.Rubber = Vector3.new(Car.WheelModels.FL.Rubber.Orientation.X,Car.WheelModels.FL.Rubber.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FL.Rubber.Orientation.Z)
Car.WheelModels.FR.Inner = Vector3.new(Car.WheelModels.FR.Inner.Orientation.X,Car.WheelModels.FR.Inner.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FR.Inner.Orientation.Z)
Car.WheelModels.FR.Rim = Vector3.new(Car.WheelModels.FR.Rim.Orientation.X,Car.WheelModels.FR.Rim.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FR.Rim.Orientation.Z)
Car.WheelModels.FR.Rubber = Vector3.new(Car.WheelModels.FR.Rubber.Orientation.X,Car.WheelModels.FR.Rubber.Orientation.Y+turnSpeed*25*-Keys.Horizontal,Car.WheelModels.FR.Rubber.Orientation.Z)
end)
Explorer:
If you can understand the reasoning I would be very glad. The Inner definitely exists workspace.PlayerCar.WheelModels.FL.Inner
I do not delete it, or alter it in any way. I have checked and it is still in the explorer from same directory.
thanks