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

Why is the = sign in the if part underlined?

local Player = script.Parent.Parent.Parent.Parent.Parent
local Per = Player:WaitForChild("Coins") -- The player file
Player:WaitForChild("Ready") -- Waits until 'Ready' appears

if script.Parent.Position = UDim2.new{0.235, 0, 0.2, 0} then
	Player.Coins.Value = Player.Coins.Value + 5
end

1 comment

2

A single = sign basically means "equals", almost as if you're setting a value. However when defining an argument the script wants two equal signs (==) to represent "is equal", otherwise it might think <= or >=.

4 answers

✓ Accepted answer

= is setting something

== is comparing

if script.Parent.Position == UDim2.new{0.235, 0, 0.2, 0} then

You aren't setting the Position of script.Parent you're checking it so you would use ==

1 comment

0

I don't see why this was downvoted, you do not need a whole paragraph just to answer a simple question.

Easy fix, just use a comparison instead of a specifier. This is what it should look like:

local Player = script.Parent.Parent.Parent.Parent.Parent
local Per = Player:WaitForChild("Coins") -- The player file
Player:WaitForChild("Ready") -- Waits until 'Ready' appears

if script.Parent.Position == UDim2.new{0.235, 0, 0.2, 0} then
    Player.Coins.Value = Player.Coins.Value + 5
end


If you dont know what comparisions are, heres a link to the forum that shows what they are.

Simple explanation: http://wiki.roblox.com/index.php?title=Conditional_statement Detailed one: http://wiki.roblox.com/index.php?title=Operator#Relational

that means that it is an error. On line 5 instead of saying if script.PArent.Position = UDim2.new() then replace the = with == so it should be

if script.Parent.Position == UDim2.new{0.235, 0, 0.2, 0} then

when you use == you are basically returning a bool value. Its saying if that statement is true/false then

= is for setting a value.

local a = "hello"

== is for comparing values.

local a = "hello"
if a == "hello" then
	--Your code here
end

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