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

attempt to index function with 'Value' error keeps showing up?

Asked by 2 years ago

I am creating a door system that only opens doors depending on your card's clearance value, and I keep recieving this error and I don't know what's wrong.

This is the entire script.

-- // variables //
local ts = game:GetService("TweenService")
local rs = game:GetService("ReplicatedStorage")
local pxps = game:GetService("ProximityPromptService")

-- // tweeninfo //
local tiswingopen = TweenInfo.new(0.576, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)
local tiswingclose = TweenInfo.new(0.605, Enum.EasingStyle.Quad, Enum.EasingDirection.Out)

-- // functions //
pxps.PromptTriggered:Connect(function(prompt)
    if prompt.Name == "DoorPrompt" then
        local door = prompt.Parent.Parent
        local config = require(door:WaitForChild("Config"))
        local open = door:FindFirstChild("Open")
        local active = door:FindFirstChild("Active")
        local locked = door:FindFirstChild("Locked")
        if door.Name == "DebugDoor" then
            local hinge = door.Hinge

            local PropertyOpen = {}
            PropertyOpen.CFrame = hinge.CFrame * CFrame.Angles(0, math.rad(-120), 0)
            local PropertyClose = {}
            PropertyClose.CFrame = hinge.CFrame * CFrame.Angles(0, 0, 0)

            local function open()
                wait(1)
                active.Value = true
                ts:Create(hinge, tiswingopen, PropertyOpen):Play()
                active.Value = false
                open.Value = true
            end

            local function close()
                wait(1)
                active = true
                ts:Create(hinge, tiswingclose, PropertyClose):Play()
                active.Value = false
                open.Value = false
            end

            prompt.Triggered:Connect(function(player)
                if player.Character:FindFirstChild("DebugCard") then
                    if not open.Value and player.Character:FindFirstChild("DebugCard").Clearance.Value >= config.clearance then
                        door.Frame.Correct:Play()
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Lime green")
                            end
                        end
                        open()
                        wait(0.5)
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Medium stone grey")
                            end
                        end
                    elseif open.Value and player.Character:FindFirstChild("DebugCard").Clearance.Value >= config.clearance then
                        door.Frame.Correct:Play()
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Lime green")
                            end
                        end
                        close()
                        wait(0.5)
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Medium stone grey")
                            end
                        end
                    elseif not open.Value and player.Character:FindFirstChild("DebugCard").Clearance.Value < config.clearance then
                        door.Frame.Incorrect:Play()
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Really red")
                            end
                        end
                        wait(0.5)
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Medium stone grey")
                            end
                        end
                    elseif open.Value and player.Character:FindFirstChild("DebugCard").Clearance.Value < config.clearance then
                        door.Frame.Incorrect:Play()
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Really red")
                            end
                        end
                        wait(0.5)
                        for i, v in pairs(door:GetChildren()) do
                            if v.Name == "Scanner" then
                                v.Light.BrickColor = BrickColor.new("Medium stone grey")
                            end
                        end
                    end
                    print("Hello world")
                end
            end)
        end
    end
end)
0
This code needs a phat rewrite. You've already got yourself a memory leak. Ziffixture 6913 — 2y
0
Anyways, your variable "open" on line 15 is overwritten by the function "open" on line 26. Ziffixture 6913 — 2y
0
Well, I'm not really that good yet so I wouldn't know. jochengael 0 — 2y

Answer this question