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

Help Script Errors?

Asked by 10 years ago

The output says that the error is around the elseif of < and >

function Click()
if workspace.StatsSave.RawPork.Value == 4 then
workspace.StatsSave.RawPork.Value = workspace.StatsSave.RawPork.Value - 4
script.Parent.Text = "Turned In"
wait(2)
script.Parent:remove()
elseif workspace.StatsSave.RawPork.Value > 4 then
workspace.StatsSave.RawPork.Value = workspace.StatsSave.RawPork.Value - 4
script.Parent.Text = "Turned In"
wait(2)
script.Parent:remove()
elseif workspace.StatsSave.RawPork.Value < 4 then
script.Parent.Text = "Not Enough Item"
wait(2)
script.Parent.Text = "Turn In"
end
end

script.Parent.MouseButton1Down:connect(Click)
1
What does the output actually say? We can't help you if you don't tell us what the error says. Tkdriverx 514 — 10y

2 answers

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
10 years ago

I'm not absolutely sure why this is erroring, especially since you didn't give any Output, but you can rewrite this logic slightly to remove some duplicate code:

function Click()
    if workspace.StatsSave.RawPork.Value >= 4 then
        workspace.StatsSave.RawPork.Value = workspace.StatsSave.RawPork.Value - 4
        script.Parent.Text = "Turned In"
        wait(2)
        script.Parent:remove()
    else --elseif isn't necessary. RawPork is either greater than or equal to 4, or less than it.
        script.Parent.Text = "Not Enough Item"
        wait(2)
        script.Parent.Text = "Turn In"
    end
end

script.Parent.MouseButton1Down:connect(Click)
0
its says the error is in line 2 :/ Anthony9960 210 — 10y
Ad
Log in to vote
-1
Answered by
Tkdriverx 514 Moderation Voter
10 years ago

The only possible error I can see is that you need to do game.Workspace instead of just workspace. I don't think this works like that anymore.

0
workspace == Workspace == game.Workspace == Game.Workspace adark 5487 — 10y

Answer this question