Hi! I was trying to loop through a folder to get all the children of that folder but it doesn’t seem to work. Do I have to do anything extra or did I call it wrong?
This script is in StarterGUI and it’s a local script
Here’s the script:
local JanitorBlocker = game.workspace:WaitForChild("JanitorBlockers") -- this is the folder
local TrelloEvent = game:GetService("ReplicatedStorage"):WaitForChild("TrelloEvent")
TrelloEvent.OnClientEvent:Connect(function(Player)
--this works but only for a single part
game.workspace:WaitForChild("JanitorBlockers"):WaitForChild("Janitor").CanCollide = false
--this loop would not work
for _, areas in pairs(JanitorBlocker:GetChildren()) do
print(areas)
areas.CanCollide = false
end
end)
I forgot to mention. I did a remote event through a server script, my bad.
local JanitorBlocker = game.workspace:WaitForChild("JanitorBlockers") -- this is the part that blocks the player from the janitor area
local TrelloEvent = game:GetService("ReplicatedStorage"):WaitForChild("TrelloEvent")
local TrelloAPI = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local BoardID = TrelloAPI.BoardsAPI.GetBoardID("Sector Leads")
local ListId = TrelloAPI.BoardsAPI.GetListID(BoardID,"🧹 Dirty Janitors")
game.Players.PlayerAdded:Connect(function(plr)
for _, JanitorNames in pairs(TrelloAPI.CardsAPI.GetCardsOnList(ListId)) do
if JanitorNames.name == tostring(plr.UserId) then
TrelloEvent:FireClient(plr)
end
end
end)
Put a print command after the TrelloEvent:FireClient(plr) to check if the person passed the trello check. This might be due to issues with the scripts associated with trello or something inputted wrong in the trello.
The code looks like it works fine.
The two outputs seem to print the same janitor blockers, but the second has a bunch of other errors/ warnings.
How many others does this not work for? Could the issue be related to another plugin which doesn’t work for them?
So what doesn’t this do? Does it print everything? Even though you started the code through a remote event from the server you still can’t change sever part’s CanCollide from the client right?
I tried but it still doesnt work, i did put a print in the loop on the client too but nothing.
client:
TrelloEvent.OnClientEvent:Connect(function(Player)
for _, part in pairs (JanitorBlocker:GetDescendants()) do
if part:IsA('BasePart') then
print(part)
part.CanCollide = false
end
end
end)
print("janitor 2")
server: (I implemented @araball222 's idea which is to add a print after it fires and it did
local JanitorBlocker = game.workspace:WaitForChild("JanitorBlockers") -- this is the part that blocks the player from the janitor area
local TrelloEvent = game:GetService("ReplicatedStorage"):WaitForChild("TrelloEvent")
local TrelloAPI = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local BoardID = TrelloAPI.BoardsAPI.GetBoardID("Sector Leads")
local ListId = TrelloAPI.BoardsAPI.GetListID(BoardID,"🧹 Dirty Janitors")
game.Players.PlayerAdded:Connect(function(plr)
for _, JanitorNames in pairs(TrelloAPI.CardsAPI.GetCardsOnList(ListId)) do
if JanitorNames.name == tostring(plr.UserId) then
TrelloEvent:FireClient(plr)
print("ServerFired")
end
end
end)
It could be the GUI and or parts haven’t loaded before the event fires.
You could add a character added connection on the server before firing the event.
Maybe something like this … Just a bit of restructuring.
local JanitorBlocker = game.workspace:WaitForChild("JanitorBlockers")
local TrelloEvent = game:GetService("ReplicatedStorage"):WaitForChild("TrelloEvent")
local TrelloAPI = require(game.ServerScriptService:WaitForChild("TrelloAPI"))
local BoardID = TrelloAPI.BoardsAPI.GetBoardID("Sector Leads")
local ListId = TrelloAPI.BoardsAPI.GetListID(BoardID, "🧹 Dirty Janitors")
game.Players.PlayerAdded:Connect(function(plr)
for _, JanitorNames in pairs(TrelloAPI.CardsAPI.GetCardsOnList(ListId)) do
if JanitorNames.name == tostring(plr.UserId) then
TrelloEvent:FireClient(plr)
end
end
end)