This script is supposed to make a GUI visible when someone approaches the intersection of US-201 and ME-3. It does. The script is also supposed to make the GUI disappear after 5 seconds. That's where the problem lies: it doesn't do that. The GUI just stays on the person's screen for eternity. I think the "or" in the if statements is causing it. I have an identical script that works perfectly fine that doesn't have "or" anywhere. Here's the script without "or"
local Part = game.Workspace:WaitForChild("BelfastVoltisonGPSSignal")
local Gui = game.Players.LocalPlayer.PlayerGui.BelfastVoltisonGPSSignalScreenGui.Frame
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.JobDestination.Value ~= "b" then
Gui.Visible = true
if game.Players.LocalPlayer.JobDestination.Value == "Augusta ME" then
Gui.TextLabel.Text = "Turn left onto Maine State Route 3"
wait(5)
Gui.Visible = false
end
end
end)
Here's the broken script that includes "or"
local Part = game.Workspace:WaitForChild("ME-3/US-201/ME-100GPSSignal")
local Gui = game.Players.LocalPlayer.PlayerGui.ME3US201GPSSignalScreenGui.Frame
Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") and game.Players.LocalPlayer.JobDestination.Value ~= "b" or "Belfast ME" then
Gui.Visible = true
if game.Players.LocalPlayer.JobDestination.Value == "Augusta ME" or "Brunswick ME" or "Rockland ME" then
Gui.TextLabel.Text = "Turn left onto ME-100/US-201"
else game.Players.LocalPlayer.JobDestination.Value = "Portland ME" or "Rumford ME" or "Farmington ME" or "Lewiston ME" or "Kingfield ME" or "Fryeburg ME" or "Biddeford ME" or "Sanford ME"
Gui.TextLabel.Text = "Continue straight to stay on ME-3"
wait(5)
Gui.Visible = false
end
end
end)

4 comments
When you use "or", it makes a completely separate statement. Because of that, you need to re-specify the value you are comparing. E.g.
if a == b or a == c thenis correct,if a == b or c thenis not actually comparing a to c. It's just seeing if c is not nil in the second instance.^not nil or false
lol (this isn't specific enough, title bot?)
Yeah but I don't know man, sorry ):