how do i activate a function on left click?
Hi...I will show you an example. This destroys a part once you click it.
function onMouseClick() --Like you asked this is calling the function. script.Parent:Destroy()--Put this script in a part end script.Parent.ClickDetector.MouseClick:connect(onMouseClick)--this connects the function so it will fire.
Hope this helps:) You also need to add a click detector and put it in the part. Feel free to accept this answer if it helped:)
Here you go!
--This little bit makes sure you have the clickdetector in it, if you already did it, remove it. local x = Instance.new("ClickDetector") x.Parent = game.Workspace.Part --whatever the name of the brick x.MaxActivationDistance = 32 --Incase if you want people to be closer or farther away from it --Actual code script.Parent.ClickDetector.MouseClick:connect(function() -- a better way than what the person above me did. faster and saves time. script.Parent.BrickColor = BrickColor.new(math.random(), math.random(), math.random()) -- this just changes it to a random color. end)
If you like it, make sure you accept this answer to help me and you out!