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

Why is the = sign in the if part underlined? [closed]

Asked by
Aepeus 59
8 years ago
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

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 >=. M39a9am3R 3210 — 8y

Locked by alphawolvess, Necrorave, Tigerism, and M39a9am3R

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

4 answers

Log in to vote
2
Answered by 8 years ago

= 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 ==

0
I don't see why this was downvoted, you do not need a whole paragraph just to answer a simple question. antonio6643 426 — 8y
Ad
Log in to vote
2
Answered by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

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

Log in to vote
0
Answered by 8 years ago

= is for setting a value.

local a = "hello"

== is for comparing values.

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