Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How do I find a player in workspace?

Asked by 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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!

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 Asherharding10 12 — 4y
0
But I don't know how to do that.. Asherharding10 12 — 4y
0
ScreenGUI or SurfaceGUI? jakeke12345 1 — 4y
Ad

Answer this question