I have a Nascar game me and a friend made, it uses a mix of tracks released by other game owners, along with cars that I edited to be less of a mess, but I have been getting issues of some peoples screens freezing and then unfreezing and they are in a different spot, or there screen feels like its stuttering kinda and that they are teleporting.
I am fairly decent at scripting but this is throwing me off and I cannot find a solution about this problem specifically. Any tips will help.
Heres a video of my friends playing and you can see his car like teleporting forwards it seems. (Sorry for it being bad quality)
robloxapp-20230326-2043190 (1).wmv (5.8 MB)
Its hard to understand your issue without your providing any scripts or other information. Could your provide the script(s) that make the cars work?
Sorry about that, its just a tank chassis cars using rotates and here is the script for the car functions.
local Debris = game:GetService("Debris")
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Replicated = game:GetService("ReplicatedStorage")
local Car = script.Parent.Parent
local VehicleSeat = Car.VehicleSeat
local Body = Car:WaitForChild("Body")
local Engine = Car:WaitForChild("Engine")
local Exhaust = Car:WaitForChild("Exhaust")
local ZonePlus = require(Replicated:WaitForChild("Knit"):WaitForChild("Modules"):WaitForChild("Zone"))
local Settings = require(Replicated:WaitForChild("Knit"):WaitForChild("Modules"):WaitForChild("Settings"))
local WheelBlur = "rbxassetid://6781056571"
local NoBlur = "rbxassetid://5368353610"
local Squeal = Car.RearAxle.Squeal
local TrackOne = Car.RearAxle.tiremark
local TrackTwo = Car.RearAxle.tiremark1
local lastDraftTime = tick()
if Settings == nil then
warn("Settings are non existant")
return
end
-- TODO: Add Gas/Tire System
-- TODO: Ability to edit how loose your car is
local detectable = {
"Back",
"Draft",
"Highline"
}
-- Settings Value
local MaxDraftSpeed = Settings.Drafts[game.PlaceId].MaxDraftSpeed
local MaxHighline = Settings.Drafts[game.PlaceId].MaxHighline
local function isDetectable(partName)
return table.find(detectable, partName) ~= nil
end
Car:MakeJoints()
VehicleSeat.Sound:Play()
-- Setting Network
VehicleSeat:GetPropertyChangedSignal("Occupant"):Connect(function(Occupant)
if VehicleSeat.Occupant == nil or VehicleSeat.Occupant.Parent == nil then
return
end
local Player = Players:GetPlayerFromCharacter(VehicleSeat.Occupant.Parent)
if Player then
VehicleSeat:SetNetworkOwner(nil) -- Make the Cars Physics Handled By Server
-- Possible Lag? Test with setting to player, Refer to https://create.roblox.com/docs/scripting/networking/network-ownership
end
end)
local function UpdateFlip()
if VehicleSeat.CFrame.upVector.Y < 0.2 then
task.wait(2)
if VehicleSeat.CFrame.upVector.Y < 0.2 then
VehicleSeat.BodyGyro.MaxTorque = Vector3.new(1000,0,1000)
end
elseif VehicleSeat.CFrame.upVector.Y >= 0.2 then
VehicleSeat.BodyGyro.MaxTorque = Vector3.new(0,0,0)
end
end
local function UpdateBlowover()
local Speed = VehicleSeat.CFrame.LookVector:Dot(VehicleSeat.AssemblyLinearVelocity)
if Speed <= -115 then
Car.RearAxle.BodyThrust.Force = Vector3.new(0, 98000, 0)
elseif Speed >= -114 then
Car.RearAxle.BodyThrust.Force = Vector3.new(0, 0, 0)
end
end
local function UpdateBlowoverSide1()
local Speed = VehicleSeat.CFrame.LookVector:Dot(VehicleSeat.AssemblyLinearVelocity)
if Speed <= -240 then
Car.Sideblowover2.BodyThrust.Force = Vector3.new(0,54000, 0)
elseif Speed >= -200 then
Car.Sideblowover2.BodyThrust.Force = Vector3.new(0, 0, 0)
end
end
local function UpdateBlowoverSide2()
local Speed = VehicleSeat.CFrame.LookVector:Dot(VehicleSeat.AssemblyLinearVelocity)
if Speed <= -240 then
Car.Sideblowover2.BodyThrust.Force = Vector3.new(0,54000, 0)
elseif Speed >= -200 then
Car.Sideblowover2.BodyThrust.Force = Vector3.new(0, 0, 0)
end
end
local function UpdateTireAnimation()
if VehicleSeat.AssemblyLinearVelocity.Magnitude < 65 then
Car.Wheels.FL.Tire.tire.Texture = NoBlur
Car.Wheels.FR.Tire.tire.Texture = NoBlur
Car.Wheels.RL.Tire.tire.Texture = NoBlur
Car.Wheels.RR.Tire.tire.Texture = NoBlur
elseif VehicleSeat.AssemblyLinearVelocity.Magnitude > 100 then
Car.Wheels.FL.Tire.tire.Texture = WheelBlur
Car.Wheels.FR.Tire.tire.Texture = WheelBlur
Car.Wheels.RL.Tire.tire.Texture = WheelBlur
Car.Wheels.RR.Tire.tire.Texture = WheelBlur
end
end
local function UpdateDynamicTorque()
if VehicleSeat.AssemblyLinearVelocity.Magnitude <= 10 then
VehicleSeat.Torque = 20
else
if VehicleSeat.Throttle == 0 and VehicleSeat.Steer == 0 then
VehicleSeat.Torque = 0.5
else
if VehicleSeat.Throttle == 1 or VehicleSeat.Throttle == -1 or VehicleSeat.Steer == 1 or VehicleSeat.Steer == -1 then
VehicleSeat.Torque = 18
end
end
end
end
local function UpdateBurnout()
if Car.RearAxle.RotVelocity.Magnitude > 1.5 then
Squeal.Volume = 2
TrackOne.Enabled = true
TrackTwo.Enabled = true
Car.Wheels.FL.smoke.Enabled = true
Car.Wheels.FR.smoke.Enabled = true
Car.Wheels.RL.smoke.Enabled = true
Car.Wheels.RR.smoke.Enabled = true
elseif Car.RearAxle.RotVelocity.Magnitude < 1.5 then
Squeal.Volume = 0
TrackOne.Enabled = false
TrackTwo.Enabled = false
Car.Wheels.FL.smoke.Enabled = false
Car.Wheels.FR.smoke.Enabled = false
Car.Wheels.RL.smoke.Enabled = false
Car.Wheels.RR.smoke.Enabled = false
end
end
local function UpdateSound()
local Speed = math.floor(VehicleSeat.AssemblyLinearVelocity.Magnitude)
local Pitch = .1
if VehicleSeat:FindFirstChild("SeatWeld") ~= nil then
VehicleSeat.Sound.Volume = .5
if VehicleSeat.Throttle > 0 then
VehicleSeat.Sound.Volume = .7
end
if Speed == 0 then
Pitch = .1
VehicleSeat.Sound.Volume = 0.1
end
if Speed < 55 and Speed > 0 then
Pitch = 0.1 +((Speed/100))
elseif Speed < 130 then
Pitch = 0.15+((Speed/200))
elseif Speed < 205 then
Pitch = 0.2+((Speed/225))
elseif Speed > 205 then
Pitch = 0.3+((Speed/350))
end
VehicleSeat.Sound.Pitch = Pitch
else
VehicleSeat.Sound.Volume = 0
end
end
local function DraftCreation()
if tick() - lastDraftTime >= 1.90 then
lastDraftTime = tick()
if VehicleSeat.Occupant ~= nil then
local Speed = VehicleSeat.AssemblyLinearVelocity.Magnitude
local Player = Players:GetPlayerFromCharacter(VehicleSeat.Occupant.Parent)
if Player and Speed >= 60 then
local Draft = Replicated.Knit.Objects.Draft:Clone()
Draft.CFrame = Car.DraftMaker.CFrame
Draft.Parent = workspace.Game.Draft
Draft:SetAttribute("Player", Player.Name)
Debris:AddItem(Draft,10)
end
end
end
end
local Sound = RunService.Heartbeat:Connect(UpdateSound)
local Draft = RunService.Heartbeat:Connect(DraftCreation)
local AutoFlip = RunService.Heartbeat:Connect(UpdateFlip)
local Burnout = RunService.Heartbeat:Connect(UpdateBurnout)
local Blowover = RunService.Heartbeat:Connect(UpdateBlowover)
local DynamicTorque = RunService.Heartbeat:Connect(UpdateDynamicTorque)
local TireAnimation = RunService.Heartbeat:Connect(UpdateTireAnimation)
local BlowoverSide1 = RunService.Heartbeat:Connect(UpdateBlowoverSide1)
local BlowoverSide2 = RunService.Heartbeat:Connect(UpdateBlowoverSide2)