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
2 years 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 — 2y

1 answer

Log in to vote
1
Answered by 2 years ago
Edited 2 years 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 — 2y
0
= is an operator Ziffixture 6913 — 2y
Ad

Answer this question