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

Trying to make a checker?

I'm trying to make a local script inside of the PlayerGui go into game.Workspace and find "Map1" or "Map2" model and this script isn't working on that part.

local found = game.Workspace:FindFirstChild("Model")
while true do
wait(2.5)
if found.Name == "Map1" or found.Name == "Map2" then 
script.Parent.MapEnabled=true
elseif found.Name == "" then
script.Parent.MapEnabled=false
end
end	

2 comments

0

What is it doing wrong?

0

10:34:59.602 - Players.Player.PlayerGui.Script:4: attempt to index local 'found' (a nil value) 10:34:59.603 - Stack Begin 10:34:59.603 - Script 'Players.Player.PlayerGui.Script', Line 4 10:34:59.603 - Stack End

1 answer

✓ Accepted answer

I moved the "local found" part around to when the loop started. I did that because it explains what found is before the script even runs.

while true do
	wait(2.5)
	local found = game.Workspace:FindFirstChild("Model")
	if found.Name == "Map1" or found.Name == "Map2" then 
		script.Parent.MapEnabled=true
	elseif found.Name == "" then
		script.Parent.MapEnabled=false
	end
end 

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