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

How do I find a player in workspace?

How do I make it so the player who click a button. It find's that specific player in the workspace. I've tried several time's but failed

1 answer

Firstly, this is not a request site. You need to at least put some effort into your code, and, assuming you are new, I would watch some tutorials before doing this; however, I will tell you what you need to do.

You need to use a ClickDetector inside of your button. What a ClickDetector does, it allows the use of certain events in a script that are called when a person clicks the part.

This is an example of what you could do. For this example, you need the parent of the ClickDetector to be the part, as well as for the script.

local clicker = script.Parent.ClickDetector

clicker.MouseClick:Connect(function(_player)
	
	
end)

On line 0, we reference the ClickDetector and assign it to the variable clicker

On line 2, we use the clicker's MouseClick event, and connect an anonymous function to be called. What this means is that anything after _player) and before end) will be called when the part is clicked.

At this point you may be wondering how we get the player. When the event is called, it passes the parameter of the player who clicked to the _player argument. You can do what you want with this.

If this solves your issue, do not forget to upvote and set this as the answer!

3 comments

0

Sorry I wan't specific enough, there's a gui button, so when a player click's it the script find's the player who clicked it in the workspace and delete's a certain script here is the script in the gui button: local clicker = script.Parent.ClickDetector script.Parent.MouseButton1Click:Connect(function(_player) script.Parent.Parent.Enabled = false workspace.CurrentCamera.CameraType = Enum.Camera

0

But I don't know how to do that..

0

ScreenGUI or SurfaceGUI?

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