I have been testing out an idea and I found something strange with how my script is working. I want to make a simple if statement where if you click a block it prints “Clicked” and if not it prints "NotClicked’
however, it runs even though its not supposed to
--Variables
local PlantBox = script.Parent
local Soil = PlantBox.Soil
local BoxFrame = PlantBox.BoxFrame
local ClickDetector = PlantBox.Soil.ClickDetector
--If the Box is clicked
if ClickDetector.MouseClick then
print("Clicked")
else
print("NotClicked")
end
I don’t know why this is happening so any help would be appreciated.
Your script is currently checking whether if a property called “mouseclick” exists under ClickDetector, and since it does exist, the if statement is considered affirmative and hence is getting executed…
So you’d have to use the :Connect statement as mentioned above in the previous post
After realizing that ClickDetector.MouseClick is an event I set it to check if it was true or not, thanks to everyone bellow I was able to come to this conclusion.