so i’m trying to get every player in a folder (folder name is “PIBF”) and activate an fire client for those players inside of the folder
the error is “GetChildren() is not a part of folder”
i’ve tried GetPlayers() but that’s only for the Players service, and also tried getting help on discord servers but my question got flooded. I’ve tried looking it up and on the forum but i just kept seeing how would add players to a folder and other things that doesn’t answer my question.
for i, v in pairs(PIBF:GetChildren()) do
remoteEvent:FireClient(v)
end
sure everything else works as intended i just put that part of it since, it’s just that section (what i’m trying to do is make the boss health change for everyone that’s in the boss level
local damage = script.Parent.Parent.Parent.Damage
local jeff = script.Parent.Parent.Humanoid
local PIBF = workspace.BosslevelPlayers
local TweenService = game:GetService("TweenService")
local health = script.Parent.Parent.Head.BillboardGui.Frame.Health
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local remoteEvent = ReplicatedStorage:WaitForChild("BossHealth")
local debounce = true
part.Touched:Connect(function(player)
local human = player.Parent:FindFirstChild("Humanoid")
if human and part.Name == "Kill" and debounce == true then
debounce = false
print(damage.Value)
human.Health = human.Health - damage.Value
elseif human and part.Name == "good" then
print("yeah?")
jeff:TakeDamage(.25)
jeff.HealthChanged:Connect(function(jeffH)
health.Size = UDim2.new(jeffH/jeff.MaxHealth,0,1,0)
local Player = game.Players:GetPlayerFromCharacter(player.Parent)
if human.Health ~= 0 then
for i, v in pairs(#PIBF:GetPlayers()) do
remoteEvent:FireClient(v, jeffH, jeff)
end
end
end)
end
wait(1)
debounce = true
end)
yeah that’s exactly what i had in mind, this is what i ended up doing. but it got to complex so i went back to doing the folder thingy. i don’t mind the table thing being complex it’s just me wondering how i’ll be able to turn it into a metatable so other scripts would be able to use those players inside of the folder
local PlayersInBossFight = {}
script.Parent.Touched:Connect(function(TouchedPart)
if TouchedPart.Parent:FindFirstChild("Humanoid") then
local character = TouchedPart.Parent
local Player = game.Players:GetPlayerFromCharacter(character)
local AlreadyInTable = false
for _,OtherPlayer in next,PlayersInBossFight do
if OtherPlayer == Player then
AlreadyInTable = true
end
end
if not AlreadyInTable then
table.insert(PlayersInBossFight,Player)
for i, val in pairs(PlayersInBossFight) do
print(val)
local PL = game.Players:FindFirstChild(val.Name).Character.PrimaryPart.Position
print(PL)
workspace.Movethis.Position = PL
attacks.addingplayer(PlayersInBossFight, PL)
end
wait(10)
end
end
end)
i don’t mind the table thing being complex it’s just me wondering how i’ll be able to turn it into a metatable so other scripts would be able to use those players inside of the (table)***
You don’t need to turn it into a metatable for other scripts being able to use it. Now I’m not entirely sure on how metatables work, so they might be a better and more performant option, so I suggest looking into those.
But if you want scripts to be able to share this table, you can turn PlayersInBossFight = {} into a ModuleScript and use it as a table.
Context of the ModuleScript would be something simple like this:
return {
}
In your script at the top you’d need to do:
local PlayersInBossFight = require(PathToModule) -- PathToModule example: game.ServerScriptService.PlayersInBossFightModule
--when they touch the block:
table.insert(PlayersInBossFight, Player)
If doing this doesn’t work, you can try to send over the table using BindableFunctions. They’re just like RemoteEvents/RemoteFunctions but used for server to server communication, which would work in your scenario.