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

Trouble with a simulated Computer OS? - functions on click detection

Asked by 10 years ago

This is the script for the computer turning on. It's a bunch of fancy renaming of a model with a humanoid and a head for effect, and the changing of the "engVal" to true, to be later called upon by other buttons to ensure that the computer is "on", for maps to be loaded.

There is a second script, within a second button, that is the "power off" function. It is exactly the same as this, except opposite in value changes and name changing.

The basic problem seems to be that I can't seem to get the player to be cross-checked with my table of "officers", the people allowed to click the buttons and operate the computer, and continue with the script.

Any help would be greatly appreciated.

-- POWER ON
officers = {"ggfunny1234", "Onzlaught", "ag4Official", "Thomas713"}

engVal = game.Workspace.Jarvis.engaged.Value

jarvis = game.Workspace.Jarvis


script.Parent.ClickDetector.MouseClick:connect(function(click)

    local plr = game.Players:GetPlayerFromCharacter(click.Parent)

    for i, v in ipairs(officers) do     

        if (plr.Name == v) and (engVal == false) then

        jarvis.Name = ("Operation Authorized. Welcome," ..plr.Name)     
        wait(2)     
        game.Workspace[('Operation Authorized. Welcome,' ..plr.Name)].Name = "Initiating Operating System.."
        wait(2)
        game.Workspace['Initiating Operating System..'].Name = "Computer Status: Online"
        wait(1)
        game.Workspace['Computer Status: Online'].Name = "Jarvis"       
        wait(1)     
        engVal = true
        wait(1)     

        elseif (engVal == true) then
            jarvis.Name = "Computer Online. Proceed."
            wait(1)
            game.Workspace['Computer Online. Proceed.'].Name = "Jarvis"


        end
    end
end)

Answer this question