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

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

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

✓ Accepted answer
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.

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