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

Help with a weapon Safety?

Asked by 8 years ago

Im trying to have weapons require a safety function, script is below with attached Gyazo of the scripts location in the model.

http://gyazo.com/481b196c3c4e91e8d1ceb9a9a7d5d9bd

C = script.Parent.Parent.Safety
local p = script.Parent:GetChildren()

function Toggle()
    if C.Value == true then
        open()
    elseif C.Value == false then
        close()
    end     
end

function open()
    for i = 1, #p do
        if p[i]:FindFirstChild("Flangs") then 
            p[i].Flangs.Transparency = 0
        end
    end
end

function close()
    for i = 1, #p do
        if p[i]:FindFirstChild("Flangs") then 
            p[i].Flangs.Transparency = 1
        end
    end

end

C.Changed:connect(Toggle)
0
Perhaps use UserInput() instead? GreekGodOfMLG 244 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

Put your Toggle function below the open and close functions ad see if that helps. As it stands now, it won't work due to order of operations in the script - the Toggle function has not visibility to your open and close functions unless they're placed before it.

Ad

Answer this question