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

What is wrong with the =?

if game.Workspace["EDM MIXER 1"].edmmix.MusicPlayer.PlaylistA.SongA1.Pitch = 1
	then script.Parent.Text = "Value: Even"
elseif game.Workspace["EDM MIXER 1"].edmmix.MusicPlayer.PlaylistA.SongA1.Pitch = 1.1
	then script.Parent.Text = "Value: +1"
end

on the = sign for line one it says expected then near =, and it doesn't work. :/

2 answers

Use "==" instead of "=" because "=" is assigning something to another thing, and "==" is comparing two things, which is what you're trying to do.

So if you're trying to set a property to true, you would say:

workspace.Part.Anchored = true

but if you wanted to check if workspace.Part.Anchored = true then you'd say:

if workspace.Part.Anchored == true then
	--code
end

1 comment

1

You can simply use "if workspace.Part.Anchored then" as the Anchored value is a boolean value so no comparison is needed.

Next time, please put your code in code block. You can do this by clicking the blue lua symbol above the text pad, then put your code inside the numeral tilde keys.



Your problem is that you're using the definition operator for a comparitive statement

= is the definition operator, it's used to define things.

==* is the comparitive operator, it's used to compare whether or not two things are identical to eachother.*



So to fix your code, on the first and third lines then just add one more equal sign(:



(NOTE: You can access the Workspace by just saying workspace. Also, assigning variables can make for much cleaner and faster code - faster meaning you don't have to retype everything)



--Lets make a variable for your song
local songa1 = workspace["EDM MIXER 1"].edmmix.MusicPlayer.PlaylistA.SongA1

--Now we can use the variable here(:
if songa1.Pitch == 1 then 
	script.Parent.Text = "Value: Even" 
elseif songa1.Pitch == 1.1 then 
	script.Parent.Text = "Value: +1"
 end

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