This looks like a very interesting system, but I have a few concerns. Allow me to go and pick out the ones that concern me most in your LocalScript. Here it is for anyone reading. It is unedited and copied straight from your system.
while true do
wait(0)
for i, v in pairs(workspace.RoadNames:GetChildren()) do -- Gets the parts in "RoadNames"
v.Touched:Connect(function() -- Checks if the part in "RoadNames" is touched
script.Parent.Text = v.Name -- Sets the text
end)
end
end
First off, you’re wrapping your code in a while true do wait() end loop. This is bad code practice. I invoke this post fleshing out why:
Secondly, the wait() function has been replaced by the task library. Lastly, your code unnecessarily connects an event to every single road every frame. You should instead just use event-based programming as described in the post above, connecting to the Touched events in your parts just once.
I’m sorry if this reply came off as a little aggressive. That was not my intention whatsoever. Here’s a quick rewrite of your script, following most proper programming practices. It’s been fully commented for your convenience
-- Services go at the top
local Players = game:GetService("Players")
-- Variables go next
local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAppearanceLoaded:Wait() -- elegantly ensures that this will only run when player is loaded
local RoadNames = workspace:WaitForChild("RoadNames")
local Label = script.Parent
local Connections = {}
local Humanoid = Character:WaitForChild("Humanoid")
-- I put connections here
for _, BasePart: BasePart --[[declare a type]] in pairs(RoadNames:GetChildren()) do -- connect events only once
table.insert(Connections, BasePart.Touched:Connect(function(otherPart) -- adds connections to a table
if BasePart:IsDescendantOf(Character) == Character then -- check if the touched part is a member of player character
Label.Text = BasePart.Name
end
end))
end
Humanoid.Died:Connect(function()
for _, connection in pairs(Connections) do
connection:Disconnect() -- clean up events on death
end
end)
I hope this helps, and I look forward to what you contribute to Roblox in the future!