[Download Starter Project]
leaderstats
local Players = game.Players
function score(Player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = Player
local Money = Instance.new("IntValue")
Money.Name = "Money"
Money.Parent = leaderstats
end
Players.PlayerAdded:Connect(score)
Driving Script
local Car = script.Parent
local Seat = Car.VehicleSeat
local FrontLeft = Car.FrontLeft
local FrontRight = Car.FrontRight
local BackLeft = Car.BackLeft
local BackRight = Car.BackRight
local SteerAngle = 30
local Speed = 50
-- KODE BELOK --
function Steer()
FrontLeft.PartB.SteeringConstraint.TargetAngle = SteerAngle * Seat.Steer
FrontRight.PartB.SteeringConstraint.TargetAngle = SteerAngle * Seat.Steer
end
Seat:GetPropertyChangedSignal("Steer"):Connect(Steer)
-- KODE MAJU --
function Move()
FrontLeft.Wheel.WheelConstraint.AngularVelocity = Speed * Seat.Throttle
FrontRight.Wheel.WheelConstraint.AngularVelocity = Speed * -Seat.Throttle
BackLeft.Wheel.WheelConstraint.AngularVelocity = Speed * Seat.Throttle
BackRight.Wheel.WheelConstraint.AngularVelocity = Speed * -Seat.Throttle
end
Seat:GetPropertyChangedSignal("Throttle"):Connect(Move)
Map Track
local PathfindingService = game:GetService("PathfindingService")
local Car = script.Parent
local CarRoot = Car.Root
local Boxes = game.Workspace.Boxes
local Prompt = Boxes.Sensor.ProximityPrompt
local TrackingPart = game.Workspace.TrackingPart
local TargetsFolder = game.Workspace.Targets
local TargetsFolderChildren = game.Workspace.Targets:GetChildren()
local TargetCounter = 0 -- Initialize the counter
function Main(Player)
-- Delivery Limit
Prompt.Enabled = false
if TargetCounter >= 3 then
Prompt.Enabled = true
TargetCounter = 0
return
end
-- Increment the target counter
TargetCounter = TargetCounter + 1
-- Random target
local Randoming = math.random(1,#TargetsFolderChildren)
local RandomTarget = TargetsFolderChildren[Randoming]
-- Tracking and DangerZone
local Path = PathfindingService:CreatePath({
Costs = {
DangerZone = math.huge
}
})
-- Settings waypoints
Path:ComputeAsync(CarRoot.Position, RandomTarget.Position)
local Waypoints = Path:GetWaypoints()
for _,Waypoint in pairs(Waypoints) do
local Track = Instance.new("Part")
Track.Size = Vector3.new(1,1,1)
Track.Position = Waypoint.Position + Vector3.new(0,2,0)
Track.Material = Enum.Material.Neon
Track.BrickColor = BrickColor.new("Lime green")
Track.CanCollide = false
Track.Anchored = true
Track.Parent = TrackingPart
end
-- New target
local PutPrompt = Instance.new("ProximityPrompt")
PutPrompt.RequiresLineOfSight = false
PutPrompt.HoldDuration = 5 -- Hold duration
PutPrompt.ActionText = "Put"
PutPrompt.Parent = RandomTarget
-- PutPrompt interact (simplified function)
PutPrompt.Triggered:Connect(function(Player)
-- Leaderstats
local leaderstats = Player.leaderstats
local Money = leaderstats.Money
Money.Value += 10 * #TrackingPart:GetChildren()
-- Delete Pervious Tracking
PutPrompt:Destroy()
for _,Track in pairs(TrackingPart:GetChildren()) do
Track:Destroy()
end
-- Reassign new target
Main()
end)
end
Prompt.Triggered:Connect(Main)
2 Likes