Hello! I am in need of help of transporting some text to a server script.
The text are players who don’t get killed once the admin executes a function from a button.
This is how it currently looks like.
game:GetService("ReplicatedStorage").KoPlayer.OnServerEvent:Connect(function(playerr, text)
local plrs = require(playerr.PlayerGui.yes.the.Settings)
wait()
if text == 'all' or text == 'All' then
for _,player in ipairs(game.Workspace.Chars:GetChildren()) do
for k,v in pairs(plrs) do
for w,o in pairs(v.Whitelists) do
if v.Requirement == true then
print(k)
if player.Name == o then --where the o starts it should reach the module script with the players names who are whitelisted.
wait(1)
print("the owner xd")
else
player.Humanoid.Health = 0
end
end
end
end
end
else
game.Players[text].Character.Humanoid.Health = 0
end
end)
Hope you don’t mind me asking but have you tried adding prints in to verify the data you are getting.
For example did you get anything from any of the for loops?
There are a few reasons why this may not be working.
First off, for the server script, why are you iterating through the workspace and then through the players, and then through the whitelists? Also you shouldn’t ever be accessing the player’s gui on the server. Next, inside your module, you’re just declaring a variable called “ModuleT” but never returning it so it never gets used.
First thing, the module:
local module = {}
module.Whitelists = {"Thewestnoy33", "Dro1z"} -- I also suggest changing to user ids instead of usernames because if the user changes their username, in that case the player will be whitelisted regardless of their username
return module
local players = game:GetService('Players')
local whitelist = require(game:GetService('ReplicatedStorage'):WaitForChild('WhitelistModule')) -- you should have the module somewhere easily accessible like replicated storage
remote.OnServerEvent:Connect(function(player, text)
if not table.find(whitelist.Whitelists, player.Name) then -- the player's name isn't available so don't grant them access
return -- doesn't proceed
end
if text:lower() == 'all' then -- making it lowercase will allow for any capitalization of the word "all" (eg. aLl)
for i,v in ipairs(players:GetPlayers()) do
if v.Name ~= player.Name then -- it's someone other than the admin who fired the remote
local character = v.Character
if not character then -- the player doesn't have a character so continue to the next iteration
continue
end
character:WaitForChild('Humanoid').Health = 0
end
end
else
local player = players:FindFirstChild(text) -- assign the player to the variable so we don't have to call the function twice
if player then -- in case the player doesn't exist
player.Character:WaitForChild('Humanoid').Health = 0
end
end
end)