Say I had a game capable of handling a maximum of 20 players, and each of those players could spawn a ship of their own.
Each ship contains a server script, and inside that script is the following:
local Ship = script.Parent
local Move = Ship:WaitForChild("Move")
local Seat = Ship:WaitForChild("VehicleSeat")
local BodyGyro = Move:WaitForChild("BodyGyro")
local BodyVelocity = Move:WaitForChild("BodyVelocity")
BodyGyro.CFrame = Move.CFrame
local Val = 0
local runService = game:GetService("RunService")
runService.Heartbeat:Connect(function()
runService.Heartbeat:Wait()
BodyGyro.CFrame = Move.CFrame
local Speed = Seat.MaxSpeed
local TurnSpeed = Seat.TurnSpeed
if Seat.Throttle == 1 then
if Val < Speed then
Val = Val + 1
end
BodyVelocity.Velocity = Move.CFrame.lookVector * Val
else
if Seat.Throttle == 0 then
Val = 0
BodyVelocity.Velocity = Move.CFrame.lookVector * Val
else
if Seat.Throttle == -1 then
if Val < 14 then
Val = Val + 1
end
BodyVelocity.Velocity = Move.CFrame.lookVector * -Val
end
end
end
if Seat.Steer == 1 then
BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, -(TurnSpeed), 0)
else
if Seat.Steer == -1 then
BodyGyro.CFrame = BodyGyro.CFrame * CFrame.fromEulerAnglesXYZ(0, TurnSpeed, 0)
end
end
end)
In other words, that’s 20 ships (maximum) using Heartbeat.
I don’t know about you, but that seems like a bad idea.
Would this cause a significant performance drop?