✓ Accepted answer
There are a ton of mistakes in your code. Let me go over them.
Firstly, it isn't good practice to put all of your variables on a single line of code. Try spacing them out a bit.
Secondly, you should be using WaitForChild if you are trying to reference objects (if your code is running right when the game starts)
For reference:
local air = script.Parent:WaitForChild('Air')
local earth = script.Parent:WaitForChild('Earth')
local fire = script.Parent:WaitForChild('Fire')
local water = script.Parent:WaitForChild('Water')
Thirdly, you don't need all of those If and Elseif statements in your code.
I am going to assume that putting all of those variables into a table would be an easier route for the query that you have, but I am not experienced in the Table world of scripting yet, so I don't want to provide any false information on that.
Anyways, below should be your fixed code (don't forget to include the variables on top.)
air.MouseButton1Down:Connect(function()
print('Air')
end)
earth.MouseButton1Down:Connect(function()
print('Earth')
end)
fire.MouseButton1Down:Connect(function()
print('Fire')
end)
water.MouseButton1Down:Connect(function()
print('Water')
end)
Please let me know if that code works or not. Once again plopping all of those into a table would probably be an easier way, but I am still learning about tables so I am not able to give any help in that field.
Anyways I hope this helps, dear friend. ????
1 comment
I also forgot to state that you had no "ends" in your code, which would also make it not work. Anyways, glad I could help. Like I said before, also please let me know if the code doesn't work because I will be glad to look over it again. It's currently 3 AM where I live so I am definitely tired. Lols