So I'm making a script (not to go into details) that uses multiple if and then statements with lots of elseif. It all seems to work until I try to end them. The end) paranthases has a red line under it but when I remove the ) it says it needs that ). So when I change the order the only thing that works makes a blue line under a bunch of things saying there unknown globally. ive seen this problem before and I'm not sure how to fix it any help would be greatly appreciated! Sorry it looks so complicated/messy. Code
local sell = script.Parent
local egg = game.Workspace.Egg
local board = game.Workspace
sell.Touched:Connect(function(part)
if part.Name == "LeftFoot" or part.Name == "RightFoot" then
if part.Parent:FindFirstChild("Egg") then
wait(2)
local egg = part.Parent:FindFirstChild("Egg")
if egg and egg.Handle.Type.Value == Common then
player.leaderstats.Dollars.Value = player.leaderstats.Dollars.Value + 5 --the 'players' gets blue underlined
wait(2)
elseif egg and egg.Handle.Type.Value == Uncommon then --the rares/uncommons etc get a blue underline
player.leaderstats.Dollars.Value = player.leaderstats.Dollars.Value + 10
wait(2)
else
wait(2)
end
else
wait(3)
end
end --switching the order of these ends messes up the things above
end) --this ) has a red line
end) --when I switch it this gets a red underline rest is good
end
end

4 comments
Ow.
https://www.robloxdev.com/articles/Writing-Clean-Code
^ and again I say Ow!
i just had a lot of messages on a billboard gui ill try to clean it up but any ideas on the issue?