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

A condition that only runs code if a certain player pushes a button on a screen gui?

Asked by 6 years ago
Edited 6 years ago

I need to make a condition that runs some code if a certain player pushes a button. If another player pushes the button the condition won't run the code.

The problem that I am having is that I don't know how to make only a certain player can run the code like "DogeDark211", I only know how to run the code if anyone pushes the button, any help would be appreciated, thanks.

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago
button = script.Parent
Player = game.Players.LocalPlayer

button.MouseButton1Click:connect(function()
    if Player.Name == "DogeDark211" then 
        -- run code
    end
end)

Hope this helps!

Player.Name gets the name of the local player and compare's it to yours.

Ad

Answer this question