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

Why do I get an error message when I use '= 3'? Can someone explain why?

Asked by
Cowgato 33
1 year ago
if game.Workspace.AmountOfOrbs.Value = 3 then
print("Hello")
end

--AmountOfOrbs is a string value btw--
0
= is the assignment operator. You mean to use ==, the equality operator Ziffixture 6913 — 1y

1 answer

Log in to vote
1
Answered by 1 year ago
Edited 1 year ago

You're using a single equal sign =, which can be used to set variables but cannot be used to compare values.

You need an operator to compare values, a double equal sign == is what you're looking for.

if game.Workspace.AmountOfOrbs.Value == 3 then
print("Hello")
end
0
that makes so much sense, thanks for your help Cowgato 33 — 1y
0
= is an operator Ziffixture 6913 — 1y
Ad

Answer this question