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

Scripts Simply Won't Detect Instances (Bug?)

Asked by 3 years ago

On a particular Roblox place save, all the scripts I make simply won't detect instances. There is no determining which instances it will see, and which ones it won't, I haven't found any correlations or patterns. It's completely random. It started when I was trying to make a simple driving script that needed to access some BoolValues located in the player's character model. I ran this code that will print what the script is able to see:

local children = workspace:GetChildren()
for i = 1, #children do
child = children[i]
print(child)
end

And for some reason, the script doesn't print any of the BoolValues that are there. I know they're there, I'm not blind. This doesn't just happen within the player's character model, it happens anywhere. Sometimes it refuses to detect parts in the workspace. I've never encountered this problem before, but I've been trying to figure this out for two days, and I've had no luck. Any idea why this is happening? Is there something I don't know?

0
tried adding a wait(), so parts can load? this may solve the issue Leamir 3138 — 3y
0
@Leamir I added wait(5) at the beginning of all my scripts. No difference. TheEthanMaverick 7 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

Ok, your method isn't the best way to go about this. You should modify your script to this:

for _,v in pairs(game.Workspace:GetChildren()) do
      print(v.Name)
end

What this script will do is cycle through every child in the workspace and set the local value "v" to that instance. Then it'll print the instance's name. If you want to go through everything in the workspace (example: part in model in workspace) you would replace :GetChildren() with :GetDescendants()

I hope this answers your question.

1
Thanks for answering. Unfortunately, I found out that the problem was occuring because a lot of the things that I needed some server scripts to access were made by local scripts, which i just learned doesn't work. Anything made by a local script cannot be seen by a server script. TheEthanMaverick 7 — 3y
0
Oh, ok IAmNotTheReal_MePipe 418 — 3y
Ad

Answer this question