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

Why am I getting this error?? (attempt to index a nil value)

Asked by 6 years ago
Edited 6 years ago

The Model named Building in ReplicatedStorage is cloned into a part called 0;0 when 0;0 is clicked. What this script should do is make the wall invisible and uncollidable if 1;0 or 0;1, another part has a building on it. It's hard to explain but you can look at the picture I linked and the code.

Thanks in advance.

http://imgur.com/a/ulMgp

http://imgur.com/a/LhoeO

http://imgur.com/a/4XnGL

Every coordinate part have the same children

while true do
    wait(1);
    if script.Parent.Parent.Parent.Name == "0;0" then
        if script.Parent.Parent.Parent.Parent:FindFirstChild("1;0").hasBuilding.Value == true then
            script.Parent:FindFirstChild("X").Transparency = 1;
            script.Parent:FindFirstChild("X").CanCollide = false;
        else
            script.Parent:FindFirstChild("X").Transparency = 0;
            script.Parent:FindFirstChild("X").CanCollide = true;
        end

        if script.Parent.Parent.Parent.Parent:FindFirstChild("0;1").hasBuilding.Value == true then
            script.Parent:FindFirstChild("Y").Transparency = 1;
            script.Parent:FindFirstChild("Y").CanCollide = false;
        else
            script.Parent:FindFirstChild("Y").Transparency = 0;
            script.Parent:FindFirstChild("Y").CanCollide = true;
        end

        script.Parent:FindFirstChild("-X").Transparency = 0;
        script.Parent:FindFirstChild("-X").CanCollide = true;
        script.Parent:FindFirstChild("-Y").Transparency = 0;
        script.Parent:FindFirstChild("-Y").CanCollide = true;
    end
end

PlaceScript

function onClicked(playerWhoClicked)
    if script.Parent.hasBuilding.Value == false then
        local building = game.ReplicatedStorage.Building:Clone();
        building.Parent = script.Parent;
        building:MoveTo(script.Parent.Position);
        script.Parent.hasBuilding.Value = true; 
    end
end

script.Parent.ClickDetector.MouseClick:connect(onClicked)
0
Cannot understand where part 0;0 or 0;1 is...Can I get proper screenshot of the workspace and game explorer? Also put script of touch event of part. Thank you , trying to help. arshad145 392 — 6y
0
Thanks, I added two more images. Please help. Thanks in advance! :) kokungen12345 15 — 6y

Answer this question