I encountered a bug inside my game, whenever i turn the vehicle to left/right, the steering wheel is supposed to turn but for some reason it doesn’t. I used network ownership for this, and it works for all the other parts. Am i supposed to change it by the server? Please help1!!1
Script:
(line 68)
local ts = game:GetService("TweenService")
local ti = TweenInfo.new(.4, Enum.EasingStyle.Quad)
local rs = game:GetService("RunService")
local char = script.Parent
local player = game.Players:GetPlayerFromCharacter(char)
local connection = nil
local seat = nil
char.Humanoid.Seated:Connect(function(active, seatPart)
if connection ~= nil then connection:Disconnect() connection = nil end
if seatPart == nil then
local attachment = nil
local height = -math.huge
for i, child in ipairs(seat:GetChildren()) do
if child.ClassName ~= "Attachment" then continue end
if child.WorldPosition.Y <= height then continue end
height = child.WorldPosition.Y
attachment = child
end
player.PlayerGui:WaitForChild("VehicleDashboard").Enabled = false
char.PrimaryPart.CFrame = attachment.WorldCFrame
seat = nil
return
end
if seatPart.Name ~= "VanSeat" then return end
seat = seatPart
local Vehicle = seatPart.Parent
seatPart.HeadsUpDisplay = false
seatPart.MaxSpeed = 100 - (Vehicle.MeshPart.Mass * 0.05)
local gui = player.PlayerGui.VehicleDashboard;gui.Enabled = true
local attachmentFL = Vehicle.PrimaryPart.AttachmentFL
local attachmentFR = Vehicle.PrimaryPart.AttachmentFR
local cylindricalBL = Vehicle.WheelBL.CylindricalConstraint
local cylindricalBR = Vehicle.WheelBR.CylindricalConstraint
local maxAngularVelocity = seatPart.MaxSpeed / (Vehicle.WheelBR.Size.Y / 2)
local Steering = Vehicle.Steering
rs.RenderStepped:Connect(function()
if gui then
local speed = seatPart.CFrame.LookVector:Dot(seatPart.Velocity)
gui:WaitForChild("Main",math.huge).Studspersecond.Text = tostring(math.floor(math.abs(speed))).. " studs/hour"
gui.Main:WaitForChild("Filler").Size = UDim2.new(0, (math.abs(speed/seatPart.MaxSpeed)*328),0,9)
end
end)
connection = seatPart.Changed:Connect(function(property)
if property == "SteerFloat" then
Steering.TargetAngle = -seatPart.SteerFloat * seatPart.TurnSpeed
local orientation = Vector3.new(0, -seatPart.SteerFloat * seatPart.TurnSpeed, 90)
ts:Create(attachmentFL,ti,{Orientation = orientation}):Play()
ts:Create(attachmentFR,ti,{Orientation = orientation}):Play()
elseif property == "ThrottleFloat" then
local torque = math.abs(seatPart.ThrottleFloat) * seatPart.Torque
if torque == 0 then torque = 2000 end
local angularVelocity = math.sign(seatPart.ThrottleFloat) * maxAngularVelocity
cylindricalBL.MotorMaxTorque = torque
cylindricalBR.MotorMaxTorque = torque
cylindricalBL.AngularVelocity = angularVelocity
cylindricalBR.AngularVelocity = angularVelocity
end
end)
end)
the bug:
External Mediahow its supposed to work:
External Media