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

Am I doing this function correctly? (I'm Beginner)

Asked by
imaA6D 39
4 years ago
Edited 4 years ago

i'm trying to make it so when a player with the same exact UserID, down below, print. (So basically what i'm trying to do is make something print whenever a player has a assigned UserID) (Sorry if I have bad English)

Code:

if game.Players.LocalPlayer.UserID = "1178643466" then print("Working") end

1 answer

Log in to vote
1
Answered by 4 years ago

This should be in a regular script.

local player = game:GetService("Players"):GetPlayerByUserId(1178643466)

game.Players.PlayerAdded:connect(function()
    if player then
        print("Player with userId 1178643466 is in this server! Their name is: " .. player.Name)
    else
        print("Player with userId 1178643466 is not in this server!")
    end
end)

if this helped mark it as answered, any further questions? comment below! :)

0
Thanks! imaA6D 39 — 4y
Ad

Answer this question