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

How can I fix the "Expected Then but got =" error?

I've tried to reformat the script so it would work but I still have no luck, I'm trying to make a script the teleports a player to a certain location if they're on Red Team but to different coordinates if they're on Blue Team, any suggestions? function Click() This is where the error is V if script.Parent.MouseButtonDown:connect(Click) and player.team = BrickColor.Red then script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27)

else if script.Parent.MouseButtonDown:connect(Click) and player.team = BrickColor.Blue script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27) end end

3 comments

0

after the BrickColor.Blue put then, That should fix it

0

Can you put your code in a lua quotes that would make it look easier to read

0

Thank you! I am new to scripting and the website so this really helped a lot, now I can keep working on my game!

2 answers

✓ Accepted answer

Please. Format your script so we can read it properly.

The error here is pretty self-explanatory. You said:

if script.Parent.MouseButton1Down:Connect(Click) and player.team = BrickColor.Red then

In the second part of the statement, you are assigning player.team to BrickColor.Red by using a single equal sign.

If you want to perform a comparison, use two equal signs.

if script.Parent.MouseButton1Down:Connect(Click) and player.team == BrickColor.Red then

Hope this helps :)

P.S.

Use variables rather than writing .Parent.Parent.Parent... a bunch of times.

local part = script.Parent.Parent

part.Name = "Part that correctly uses variables"

And use Connect rather than connect.

The Error "Expected Then but got =" Means that you are missing a "Then"

How To Fix it?

It is really easy to fix this error. Simply add a "then" Because if you have an "If" sentence you need to add a "Then" to justify what to do when it matches the "If" Sentence.

For example If Part.BrickColor = Red Then Part.Transparency = 1 [Not The Best At Giving Example]

To fix your script, simply add Then After BrickColor.Blue

Here is the Script

else if script.Parent.MouseButtonDown:connect(Click) and player.team = BrickColor.Blue then 
script.Parent.Parent.Parent.Parent.Character.HumanoidRootPart.CFrame = CFrame.new(-13.2, 0.5, -35.27) end end

Hope This Helps.

And Please Format your script correctly, so it's easier for others to read and fix your script!

Have Fun scripting!

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