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

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

Asked by 6 years ago

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

0
after the BrickColor.Blue put then, That should fix it seith14 206 — 6y
0
Can you put your code in a lua quotes that would make it look easier to read seith14 206 — 6y
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! Draxslayer539AbRA 6 — 6y

2 answers

Log in to vote
0
Answered by
chomboghai 2044 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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.

Ad
Log in to vote
0
Answered by 6 years ago

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!

Answer this question