Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Scripts do not detect parts in a workspace folder?

My game was pretty laggy, and I knew why. It was due to the npcs' follow scripts scanning every part of the workspace. I decided to put all non-npc models and parts in a folder in the workspace called "World". I changed some toolgiver scripts to detect the toolgivers in the folder instead of the workspace itself, however the scripts do not seem to detect anything inside the toolgivers, specifically the "Head". I even put a workspace.World.Toolgiver:WaitForChild("Head")... statement but that didn't work either. It sees everything in the toolgiver nil and I don't know why or how to fix this. The problem seems to only occur in the server script

The localscript:

workspace.World["Toolgiver"]:WaitForChild("Head").ClickDetector.MouseClick:Connect(function()
	if plr.Backpack:FindFirstChild("Tool") == nil then
		workspace.World["Toolgiver"]:WaitForChild("Head").event:FireServer()
	end
end)

The script in ServerScriptService:

workspace.World["Toolgiver"]:WaitForChild("Head").event.OnServerEvent:Connect(function(p)
	game.ReplicatedStorage.Tools["Tool"]:Clone().Parent = p.Backpack
end)

6 comments

0

Which toolgiver are you using? Can you send us a model of it?

0

oh it's one that I made. it's a model that has only one block (that being the "Head") and I put a remoteEvent inside called "event". The thing is it worked before I put it in a folder, but all of a sudden the game won't detect the Head in the model

0

and I put a clickdetector and a humanoid in it

0

Did you spell the Toolgiver name right?

0

also using game.Workspace is best

0

what I get in the output is Infinite yield possible on 'Workspace.World.Toolgiver:WaitForChild("Head")'

1 answer

So it turns out there was another model without a part called "Head" that had the same name as the toolgiver

This discussion is preserved as it was. New answers, comments, and votes are closed.