How to fix Expected 'then' when parsing if statement, got '='

Hey, I was wondering if there was a way to fix this error message “Expected ‘then’ when parsing if statement, got ‘=’” Here’s the script that the error message is appearing in:

local cp = 0
local plr = game.Players.LocalPlayer
while wait() do
if cp ~= plr.leaderstats.DIAMONDS.Value = addtitle(playerData.Statistics.Diamonds) then ← Error line message
local random = math.random(1,900)
local xnew = random/1000
local new = game.ReplicatedStorage.ShowAdd:Clone()
new.Parent = script.Parent.Main
new.Position = UDim2.new(xnew,0,1,0)
new.Text = “+”…plr.leaderstats.DIAMONDS.Value = addtitle(playerData.Statistics.Diamonds) - cp…“:gem:
cp = plr.leaderstats.DIAMONDS.Value = addtitle(playerData.Statistics.Diamonds)
end
end

local cp = 0
local plr = game.Players.LocalPlayer
while wait() do
if cp ~= plr.leaderstats.DIAMONDS.Value == addtitle(playerData.Statistics.Diamonds) then ← Error line message
local random = math.random(1,900)
local xnew = random/1000
local new = game.ReplicatedStorage.ShowAdd:Clone()
new.Parent = script.Parent.Main
new.Position = UDim2.new(xnew,0,1,0)
new.Text = “+”…plr.leaderstats.DIAMONDS.Value = addtitle(playerData.Statistics.Diamonds) - cp…“:gem:
cp = plr.leaderstats.DIAMONDS.Value = addtitle(playerData.Statistics.Diamonds)
end
end

this should fix it

The = in the if statement is supposed to be == or >= or <=

3 Likes

Got it working now. Thank you for the assistance.