Hey there everyone,
I’ve been working on a project of mine, but I am a bit stuck. I’m trying to get something to print when a player joins. Here is my full script:
-- Editable Features:
local username = "FxllenCode" -- Username of whitelisted user goes here, used for remote event.
local allowed = 82738847 -- UserID of whitelisted user goes here.
local commandStart = "!startAlerts" -- You can change this to whatever you want.
local commandEnd = "!endAlerts" -- This one too.
-- Do not touch the lines below unless you know what your are doing.
local Players = game:GetService("Players")
local check = false
local enabled = false
local confirm = false
local cache = {}
function getUserIdFromUsername(name)
-- First, check if the cache contains the name
if cache[name] then return cache[name] end
-- Second, check if the user is already connected to the server
local player = Players:FindFirstChild(name)
if player then
cache[name] = player.UserId
return player.UserId
end
-- If all else fails, send a request
local id
pcall(function ()
id = Players:GetUserIdFromNameAsync(name)
end)
cache[name] = id
return id
end
function checkForPerms(name)
local id = getUserIdFromUsername(name)
if id == allowed then
check = true
print("Sound Perms")
print(id)
else
check = false
print("No perms")
print(id)
end
end
function pausePerms(player)
if enabled == true then
confirm = false
enabled = false
end
end
function confirmPerms(player)
if check == true then
confirm = true
while confirm == true do
enabled = true
print("plsplspls")
wait(5)
end
end
end
Players.PlayerAdded:Connect(function(player)
checkForPerms(player.Name)
end)
game.Players.PlayerAdded:Connect(function(player) -- call the yes
player.Chatted:Connect(function(message)
if message == commandStart then
confirmPerms(player)
print("im not an idiot yay")
end
end)
end)
game.Players.PlayerAdded:Connect(function(player) -- stop calling the yes
player.Chatted:Connect(function(message)
if message == commandEnd then
pausePerms(player)
print("me not big dumb")
end
end)
end)
while enabled == true do
if game.Players.PlayerAdded:Connect() then
print("someone joined :oooooooo also i didnt fail me large happy")
wait(4)
end
end
print(check)
print(allowed)
print()
If possible, help would be appreciated! I am kind of a novice scripter, so please be sure to explain the solution in detail and give me all the little bits and pieces so I can learn!
Thank you so much! ![]()