How would I make a click detector?

I am wondering how I would make a working click detector script that will changed the properties of another object. I can script a very little amount. Thanks.

Two people gave me good answers so I can’t choose one for a solution! Thanks for your help.

What sort of properties? Size? Position?

If so, try this:

script.Parent.ClickDetector.MouseClick:Connect(function()
game.Workspace.PartNameHere.Size = game.Workspace.PartNameHere.Size + Vector3.new(0,10,0)
end)
1 Like

The properties I am wanted to change are Transparency and CanCollide.

I will try your script thanks!

    script.Parent.ClickDetector.MouseClick:Connect(function()
    game.Workspace.PartNameHere.Transparency = 0.5
    game.Workspace.PartNameHere.CanCollide = true
    end)

Should work!

1 Like

Hello there! Have you looked around the Dev Forums on this topic? There are many resources that you could find on Click Detectors! :slightly_smiling_face:

So going about learning how to script Click Detectors, there is a very resourceful developer API in which you can learn how to create and script click detectors, this can be found here:

Here is an example from the Developer API that I edited, on changing the properties of a Door Part!

-- The door 'BasePart'
local door = script.Parent

-- Create a ClickDetector
local ClickDetector = Instance.new("ClickDetector")
ClickDetector.Parent = door
ClickDetector.MaxActivationDistance = 10

-- Open door on left mouse click
ClickDetector.MouseClick:Connect(function()
door.Transparency = 0.8
door.CanCollide = false
wait(1)
door.Transparency = 0
door.CanCollide = true
end)
4 Likes

I feel like this could of been solved with very little research.

2 Likes

Nothing wrong with asking though.

1 Like

I actually find it very annoying reading or replying to posts that could of been solved with a two minute search. It’s also wasting your time asking as well, as you probably didn’t get the answer as fast as a quick search.

4 Likes

Then don’t read it if it annoys you then.

How am I to know that you weren’t trying to make a more complicated type of click detector? There’s many topic titles that lack detail, I had no idea that this wasn’t one of them. Also, I will not be replying anymore after this reply, it is getting off topic.

1 Like