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

How can I insert things into a certain player who clicks a button?

Asked by 5 years ago

I want to try and insert a dialog, and a sound into a player when they click a button. I'm not sure how to do this. This was my attempt (it doesn't work and I don't really understand the whole :GetPlayer stuff yet)

01local button = script.Parent
02local name = game.Players:GetFullName(game.Players:GetPlayerFromCharacter)
03local dialog = game.ServerStorage.Dialog:Clone()
04local talk = button.Talk:Clone()
05button.ClickDetector.MouseClick:Connect(function()
06    local playerw = name
07    dialog.Parent = playerw.Head
08    talk.Parent = playerw.Head
09    playerw.Head.Talk.Playing = true
10end)

Sorry for how messy it is, I was just lost. I really have no clue on this one.

0
I know this is kind of a stupid question i just don't know how to do that Just_Moop 27 — 5y
0
there's no real need to do that, u could just do this, function(andputhereanything, that's gonna be ur player) BANSA168 15 — 5y
0
wow BANSA168 so helpful totally understand that YTEqrypted_Eqrypto -16 — 5y
0
Yeah i just found that out thanks so much. Just_Moop 27 — 5y
View all comments (2 more)
0
I don't think this question deserves a downvote, he provided code, he just didn't know how to get the player OBenjOne 190 — 5y
0
Also whoever gave that downvote should provide a reson next time OBenjOne 190 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

This is not that complicated. All you need is the parameter playerWhoClicked, which is built into Roblox. If your having trouble, make sure to take a look at the DevHub.

Note: Considering you haven't guessed already, the parameter playerWhoClicked is literally the player who clicked.

https://developer.roblox.com/en-us/api-reference/event/ClickDetector/MouseClick

Anyways, here is the code :

1button.ClickDetector.MouseClick:Connect(function(playerWhoClicked)
2 
3        local dialog = game.ServerStorage.Dialog:Clone()
4        local talk = button.Talk:Clone()
5        talk.Parent = playerWhoClicked.Character.Head
6        dialog.Parent = playerWhoClicked.Character.Head
7        talk.Playing = true
8 
9end)

I'm not sure if this code works, but if it doesn't, please contact me back and I will be able to help some more.

Ad
Log in to vote
0
Answered by 5 years ago

Just type after (function(Player) and that is your player

Answer this question