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

Trying to make a checker?

Asked by 9 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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 
0
What is it doing wrong? Relatch 550 — 9y
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 ScriptingCon 52 — 9y

1 answer

Log in to vote
0
Answered by
Relatch 550 Moderation Voter
9 years ago

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 
Ad

Answer this question