How can i make this?

Hey there!
So, I already have a topic of this problem, let me explain what I have been trying to do.

I want to make a location system where a script locates how much distance there’s from main block (where script is located) to another workspace block or model. This is for vehicles.

Then, when the script already located the model or block, it should calculate how much seconds or minutes (aprox.) there are until the model reaches main block.

With that information, the script checks inside the located model, on the vehicle body, a text label with is a destination (because it’s a bus). When script get’s that information, with all the rest of information, Inside the main block (where as I said, script is located there) there are some different text labels, and the script just needs to display all the taken information of how much left for the bus or vehicle to arrive, the text label (destination) & all that the script got, (except distance witch only will be displayed on minutes/seconds).

I’ve already tried making that kind of system but didn’t get results, nothing is working and there are no apparently errors on console or with script, (you have an url with the other topic about this).

So here is the old script witch didn’t got me with any results after a lot of modifications or anything that people told me on forum.

local targetBlock = workspace.BMC
local mainBlock = workspace.Model
local label1 = workspace.Model.SignFront.Front.Line1.Time
local label2 = workspace.Model.SignBack.Back.Line1.Time
local targetLabel = workspace.BMC.Main.Body.Destination.MainSign.SurfaceGui.Num

while true do
	local distance = (targetBlock:GetPivot().Position - mainBlock:GetPivot().Position).Magnitude
	local timeInMinutes = distance / 60

	if timeInMinutes <= 1 then
		label1.Text = "Inminente"
		label2.Text = "Inminente"
	else
		label1.Text = targetLabel.Text
		label2.Text = targetLabel.Text
	end

	targetLabel = workspace.BMC.Main.Body.Destination.MainSign.SurfaceGui.Num
	label1.Text = targetLabel.Text
	label2.Text = targetLabel.Text

	wait(10)
end

So, i’m asking to someone who is interested on helping me out with this, to simply re-make the script for making that functions as I explained, as I think re-using again this script is not getting anywhere after trying with it a lot of times.

Thanks to anyone who is interested on helping me with this, I’ll be looking for replies, do not dude on asking any other information for complete script or system!

If you want to track bus routes through this script, you will need some type of system to do so. With that system you’d essentially need to calculate the time to each stop and then add it. For say I have one stop that’s 2 minutes away, then next 4 minutes away, then the stop with the script (in this example, they all will) is 7 minutes away. Adding 2+4+7 would give users the time until the bus is at that stop.

I can’t tell if you were experiencing issues with the magnitude or timing, because I personally have had no issues when using it in studio with some minor adjustments.

I can help you get started on a script like this if you need the help.

You have some kind of model or tutorial or you want to make it at studio?

I would share you a studio place for test it out, as my developer team is still working on the map.

I can get you started here. I would recommend using a modular script under every bus that you have. Then put all the busses in some type of folder so they can all be found using :GetChildren. Under each bus I’d recommend putting a value or something to say the next stop, although you could change this.
In that modular script, say the bus has a pre-configured route.
You can try something like this.

local stops = {
	[1] = {Vector = Vector3.new(30,0,10), Stop = "Gooseberry"},
	[2] = {Vector = Vector3.new(70,0,15), Stop = "Berry"},
	[3] = {Vector = Vector3.new(394,0,39), Stop = "Lootown"}
}
local StepProgress = 0
--You can change BusSystem, but you have to change both of them. Not just this one.
local BusSystem = {}
function BusSystem:GetNextStop(YourStop: string)
	local totalTime = 0
	for i, stop in ipairs(stops) do
		local distanceFromNextStop = (stop.Vector - script.Parent.Position).Magnitude
		local timeToNextStop = distanceFromNextStop / 60
		totalTime = totalTime + timeToNextStop
		if stop.Stop == YourStop then
			local Return = {totalTime, stop.Stop}
			return Return
		end
	end
	print("Stop not found: " .. YourStop)
end




return BusSystem

Now, in your main script to get time you would first require the file local File = require(workspace.Bus.ModularScript), then you would call it with local Time = FileName:GetNextStop("StopName"), Making sure the Stop name is in the file. Then you’d do for example Time[1] to get the time, and Time[2] to get the stop, which has already been sent.

The rest is up to you, as this should only be used as a baseline.

Thank you so much for the help, but I already made another system, not for this but I would like to use it for make easier this one, let me explain:

I made a system witch announces next stop hitting certain parts on the map, so I would like that every time the Bus hits the stop block witch is also used for announce the stop we’re at, we add certain amount of minutes to the next stop counter, I would like to make it for start of 2-3 stops, but for later, I would like that it’s possible to add more stops for the system, if you can make me this, I would really appreciate a lot, thanks! Do not dude on asking me anything that you need in order for complete this :wink:

1 Like