I’m attempting to run a few basic lines of code just to get a grip of a few things I haven’t experimented with before. I’m trying to run a local script in starter player scripts because I want this only to be achievable by the client. However it just won’t run and I can’t seem to find out why. The code works perfectly as intended because if I put in in a normal script and in the workspace It will run properly.
local descendants = workspace.Tiles:GetDescendants()
for _, descendant in pairs(descendants) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end
It should be related to client trying to run a script on an non loaded part so I guess using waitforchild and a litlle task.wait() in for loop may do the job
Yeah I made a few modifications and this seems to work!
local descendants = workspace:WaitForChild("Tiles"):GetDescendants()
local tiles = game.Workspace:WaitForChild("Tiles")
local function modifyTilesColor()
while true do
for _, descendant in pairs(tiles:GetDescendants()) do
if descendant:IsA("BasePart") then
descendant.BrickColor = BrickColor.Green()
end
end
task.wait(1)
end
end
modifyTilesColor()