Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Help Script Errors?

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 comment

1

What does the output actually say? We can't help you if you don't tell us what the error says.

2 answers

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)

1 comment

0

its says the error is in line 2 :/

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.

1 comment

0

workspace == Workspace == game.Workspace == Game.Workspace

This discussion is preserved as it was. New answers, comments, and votes are closed.