Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a script that detects when a player clicks something?

I want to make a horror game that includes a bot that detects when a player opens/closes a door. I also need the script to include a sensor (or whatever it's called) that focuses on the nearest location so the bot doesn't gets distracted by other players.

Thanks if you answer this!

2 answers

you can do a random part as a example and insert a part:

local clickdetector = Instance.new("ClickDetector", script.Parent)
local openorclose = 0

if clickdetector.MouseClick then
	if openorclose == 0 then
		print("door have been opened!")
		openorclose = 1
	else
		print("door have been closed!")
	end
end

so simply you can use a value to sensors open or not, its simple, right?

If you have any more question, say below comment, I will be very happy to help!

1 comment

0

Ps: clickdetector you can find out more in the RunKittenzRComin's answer

This discussion is preserved as it was. New answers, comments, and votes are closed.