Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Script was working ~1 week ago but no longer does?

Asked by 6 years ago

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.

01math.randomseed(tick)
02local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare")
03local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame
04Part.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"
View all 34 lines...
0
Maybe roblox has updated some features? Or you might still be trying to code in Experimental mode... BabyDevil285 9 — 6y
0
FE is enabled. sesamert16 31 — 6y
0
And, in this game, it always has been. sesamert16 31 — 6y
0
math.random(3) won't work. Tell me what you are trying to achieve with that line of code BabyDevil285 9 — 6y
View all comments (5 more)
0
Maybe it has a virus? DjMusa2 81 — 6y
0
if you're not using dark mode already do that and it fixes your problem User#19524 175 — 6y
0
math.random(3) gets a random number between 0 and 3, right? I saw the line math.random(100) on the roblox wiki's page about math.random in one of their demo script things. How can Roblox Studio get a virus unless your entire computer has a virus, which mine doesn't? sesamert16 31 — 6y
0
The dark theme didn't do anything. sesamert16 31 — 6y
0
math.randomseed(tick) is the issue. Did it get deprecated when nobody was looking or something? I know because I put it right before math.random and the GUI popped right up but the text on the textlabels/textbuttons was "label" or "button." Anyone know why? sesamert16 31 — 6y

2 answers

Log in to vote
1
Answered by
DjMusa2 81
6 years ago

Here is the correct script (you could answer this one instead of answering yours)

01math.randomseed(tick())
0202  local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare")
0303  local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame
0404  Part.Touched:Connect(function(hit)
0505      if hit.Parent:FindFirstChild("Humanoid") then
0606          if game.Players.LocalPlayer.Job.Value == "a" then
0707              Gui.Visible = true
0808              local number = math.random(3)
0909              if number == 1 then
1010              Gui.TextButton.Text = "SellGoods    -    Belfast ME"
1111              Gui.TextLabelMoney.Text = "553"
1212              Gui.TextLabel.Text = "46"
1313              Gui.City.Value = "Belfast ME"
1414              elseif number == 2 then
1515                  Gui.TextButton.Text = "SellGoods    -    Augusta ME"
View all 34 lines...
Ad
Log in to vote
0
Answered by 6 years ago

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:

01math.randomseed(tick())
02local Part = game.Workspace:WaitForChild("AugustaTidbitGreenSquare")
03local Gui = game.Players.LocalPlayer.PlayerGui:WaitForChild("AugustaTidbitScreenGui").Frame
04Part.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"
View all 34 lines...
0
Nvm. Guess I can't accept my own answer. sesamert16 31 — 6y

Answer this question