Hey there, so i'm making a button, if you click it you will recieve a pop up. But i want this to work for only one (or a couple) players. How can i do this? (Be sure that it works with player ID's)
Also please be specific.
Hey there, so i'm making a button, if you click it you will recieve a pop up. But i want this to work for only one (or a couple) players. How can i do this? (Be sure that it works with player ID's)
Also please be specific.
-- Var --
local Player = game.Players.LocalPlayer
local Button = script.Parent.Button -- Change this to your button
local Player1 = 000000000 -- Change these to your ids
local Player2 = 000000000
local Player3 = 000000000
local Player4 = 000000000
local Player5 = 000000000
local function listed()
print("You are on the list!")
-- Do something if the player is on the list
end
local function notlisted()
print("You are not on the list!")
-- Do something if the player is not on the list
end
-- Script --
Button.MouseButton1Click:Connect(function()
if Player.UserId == Player1 then
listed()
elseif Player.UserId == Player2 then
listed()
elseif Player.UserId == Player3 then
listed()
elseif Player.UserId == Player4 then
listed()
elseif Player.UserId == Player5 then
listed()
else --Add more elseif if you have more player ids
notlisted()
end
end)
This isn't the most efficient script but its the first thing that came to mind, hope it helps!
this is horribly made
why dont you use tables? idk how to use them but im pretty sure it would make your script look much cleaner than this lol Example: local ids = {000000000 ,000000000 ,000000000 ,000000000 }
local ids = {}--put some ids in here and seperate them with a comma
local player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function()
if table.find(ids,player.UserId) then
--you got it from here
end
end
good lord thank you so much, the answer which was accepted is giving me anxiety
could you give me the points for helping answer instead of that guy?
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
Do you mean custom ID's, or the roblox ID's made for each roblox account?