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

Getting Confused on how to locate EVERYONE in a server script. help?

Asked by 6 years ago

So I've Made a local script which every time a player joins it checks to see if the player is in the list/table if that person is then the GUI/TextButton Shows up. heres the script

local players = game:GetService("Players")

function addPlayer(player)
    local isVip = {["WillBe_Stoped"] = true, [""] = true, [""] = true,[""]= true,[""]= true,[""]= true}
    if isVip[game.Players.LocalPlayer.Name] then
    script.Parent.Visible = true
    end
end


for _,player in pairs(players:GetPlayers())do
    addPlayer(player)
end


players.PlayerAdded:connect(addPlayer) -- local script (This one works)
-- I added this script to show what im doing

Now for my other scripts. This one is inside the TextButton so when you click it, it should fire an event.

script.Parent.MouseButton1Click:Connect(function()
    game.ReplicatedStorage.DisableBalls:FireServer()
end) -- also a local script

now for my final script

game.ReplicatedStorage.DisableBalls.OnServerEvent:Connect(function()
    -- inside here i have no idea what to put.(Im tryning to make it so that when the Admin/VIP person Clicks the TextButton It Should Disable another GUI for everyone else)
end)

i may suck at explaining but you can ask me questions in comments xd

1 answer

Log in to vote
1
Answered by
awfulszn 394 Moderation Voter
6 years ago
Edited 6 years ago

Well, if you wanted to get every player within the server script, a simple for loop should suffice.

for _, v in pairs(game.Players:GetPlayers()) do
  -- code
end

This for loop iterates through all the players in your game. You can change something about the player by referencing v, such as v.PlayerGui.

I hope my answer has somewhat helped you, if it did remember to accept it. If you require further assistance, then please let me know! :)

0
Yo i tried doing it in game but it did not work i dont really understand since I don't have any idea where to put the "OnServerEvent" WillBe_Stoped 71 — 6y
Ad

Answer this question