UPDATE: Please test your scripts before submitting them.
I need this for a test world to prevent others from coming in, but it doesn't seem to work online.
function removeplayer(player) print(player.Name .. " has been kicked for attempting entry.") player:remove() end function onPlayersEntered(tobechecked) wait() if not tobechecked.Name == "Player1" or not tobechecked.Name == "luigi970p" then -- Change luigi970p to your name wait(1) removeplayer(tobechecked) end end game.Players.ChildAdded:connect(onPlayersEntered)
game.Players:connect(function(player) print(player.Name .. " has been kicked for attempting entry.") player:Kick() wait() if not tobechecked.Name == "Player1" or not tobechecked.Name == "luigi970p" then wait(1) removeplayer(tobechecked) end end) -- This is all I could find that was a problem to me.
Here, I kind-of edited your code, I think it should work now;
local function SB(code,par) --My own personal Script Builder code local Code = Instance.new("StringValue",par) --This will create a new StringValue, and set its Parent to par Code.Value = code --The Value of the StringValue will equal to code repeat wait(0) until Code.Value == code --This will repeat waiting until the Value is equal to code loadstring(Code.Value)(); --After so, will run the Code wait(1/19) --Waits, oh say, 0.052631578947368 miliseconds? if Code ~= nil then --If Code is still existant then Code:Destroy() --It will Destroy the StringValue end --This end ends the code for the 'if' statement end --This end ends the code for the function local function OwnerJoin(plr) --This function will be used to check if the Player is the owner or not repeat wait(0) until plr and plr.userId and plr:FindFirstChild("PlayerGui") and game.CreatorId --This will repeat waiting until the script finds these requiements if plr.userId == game.CreatorId then --If the Player's UserID matches to the game Owners then print(plr.." is an Owner") --It will print that the Player is the Owner else --Elseif the Player's UserID doesn't match then SB("repeat until nil",plr.PlayerGui) --Heres our second function! end --This end ends the code for the 'if' statement end --This end ends the function game.Players.PlayerAdded:connect(OwnerJoin) --Now, whenever a Player joins, it will fire this event for i,v in pairs(game.Players:GetPlayers()) do OwnerJoin(v) end --This is used as a just-in-case
Hope this helped! :)