Reposted due to no answers being posted on my last post.
This is a problematic script. I asked this question ~1 month ago, added WaitForChild to the second line, and that was that, everything was working fine again. However, the script broke again. It just doesn't work this time.
When the script is working, it brings up a GUI if someone's "Job" value is Job's default value. If the Job value is the name of the facility followed by the city it is in, it'll pay you for the delivery, add the miles you drove to the leaderstat, and reset everything. If your "Job" value is its default, it will create a random number between 1 and 3 and depending on that number it will update the GUI's text buttons and such with the properties of the job corresponding to that number.
There are no output errors or anything, it just doesn't work anymore. Does anyone know why? This script is a local script.
math.randomseed(tick) local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare") local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame Part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if game.Players.LocalPlayer.Job.Value == "a" then Gui.Visible = true local number = math.random(3) if number == 1 then Gui.TextButton.Text = "SellGoods - Belfast ME" Gui.TextLabelMoney.Text = "553" Gui.TextLabel.Text = "46" Gui.City.Value = "Belfast ME" elseif number == 2 then Gui.TextButton.Text = "SellGoods - Augusta ME" Gui.TextLabelMoney.Text = "56" Gui.TextLabel.Text = "1" Gui.City.Value = "Augusta ME" elseif number == 3 then Gui.TextButton.Text = "Wallbert - Augusta ME" Gui.TextLabelMoney.Text = "47" Gui.TextLabel.Text = "2" Gui.City.Value = "Augusta ME" elseif game.Players.LocalPlayer.Job.Value == "Tidbit - Augusta ME" then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + game.Players.LocalPlayer.ToBePaid.Value game.Players.LocalPlayer.ToBePaid.Value = 0 game.Players.LocalPlayer.leaderstats.MilesDriven.Value = game.Players.LocalPlayer.leaderstats.MilesDriven.Value + game.Players.LocalPlayer.MilesToBeDriven.Value game.Players.LocalPlayer.MilesToBeDriven.Value = 0 game.Players.LocalPlayer.Job.Value = "a" game.Players.LocalPlayer.JobDestination.Value = "b" end end end end)
Here is the correct script (you could answer this one instead of answering yours)
math.randomseed(tick()) 02 local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare") 03 local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame 04 Part.Touched:Connect(function(hit) 05 if hit.Parent:FindFirstChild("Humanoid") then 06 if game.Players.LocalPlayer.Job.Value == "a" then 07 Gui.Visible = true 08 local number = math.random(3) 09 if number == 1 then 10 Gui.TextButton.Text = "SellGoods - Belfast ME" 11 Gui.TextLabelMoney.Text = "553" 12 Gui.TextLabel.Text = "46" 13 Gui.City.Value = "Belfast ME" 14 elseif number == 2 then 15 Gui.TextButton.Text = "SellGoods - Augusta ME" 16 Gui.TextLabelMoney.Text = "56" 17 Gui.TextLabel.Text = "1" 18 Gui.City.Value = "Augusta ME" 19 elseif number == 3 then 20 Gui.TextButton.Text = "Wallbert - Augusta ME" 21 Gui.TextLabelMoney.Text = "47" 22 Gui.TextLabel.Text = "2" 23 Gui.City.Value = "Augusta ME" 24 elseif game.Players.LocalPlayer.Job.Value == "Tidbit - Augusta ME" then 25 game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + game.Players.LocalPlayer.ToBePaid.Value 26 game.Players.LocalPlayer.ToBePaid.Value = 0 27 game.Players.LocalPlayer.leaderstats.MilesDriven.Value = game.Players.LocalPlayer.leaderstats.MilesDriven.Value + game.Players.LocalPlayer.MilesToBeDriven.Value 28 game.Players.LocalPlayer.MilesToBeDriven.Value = 0 29 game.Players.LocalPlayer.Job.Value = "a" 30 game.Players.LocalPlayer.JobDestination.Value = "b" 31 end 32 end 33 end 34 end)
I'm not sure if writing an answer to my own question and then accepting it is against the ToS or something, but I'm going to do it in case somebody else with a similar issue is coming here looking for an answer. The issue was in line 1, with math.randomseed(tick()). I figured that out by moving that line to the line before math.random - that made the GUI pop up, but have nothing on it. What happened was I forgot to put parentheses within the first set of parenthesis - I put math.randomseed(tick) instead of math.randomseed(tick()). The correct script would be this:
math.randomseed(tick()) local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare") local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame Part.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then if game.Players.LocalPlayer.Job.Value == "a" then Gui.Visible = true local number = math.random(3) if number == 1 then Gui.TextButton.Text = "SellGoods - Belfast ME" Gui.TextLabelMoney.Text = "553" Gui.TextLabel.Text = "46" Gui.City.Value = "Belfast ME" elseif number == 2 then Gui.TextButton.Text = "SellGoods - Augusta ME" Gui.TextLabelMoney.Text = "56" Gui.TextLabel.Text = "1" Gui.City.Value = "Augusta ME" elseif number == 3 then Gui.TextButton.Text = "Wallbert - Augusta ME" Gui.TextLabelMoney.Text = "47" Gui.TextLabel.Text = "2" Gui.City.Value = "Augusta ME" elseif game.Players.LocalPlayer.Job.Value == "Tidbit - Augusta ME" then game.Players.LocalPlayer.leaderstats.Money.Value = game.Players.LocalPlayer.leaderstats.Money.Value + game.Players.LocalPlayer.ToBePaid.Value game.Players.LocalPlayer.ToBePaid.Value = 0 game.Players.LocalPlayer.leaderstats.MilesDriven.Value = game.Players.LocalPlayer.leaderstats.MilesDriven.Value + game.Players.LocalPlayer.MilesToBeDriven.Value game.Players.LocalPlayer.MilesToBeDriven.Value = 0 game.Players.LocalPlayer.Job.Value = "a" game.Players.LocalPlayer.JobDestination.Value = "b" end end end end)