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

what did I do wrong with this card reader script?

Asked by 9 years ago

Hello, Ive made a script, everything works fine, but the lowest part with the card reader wont do anything. the script is

model = script.Parent
reader = model.CardReader
Menu = model.Menu
keys = Menu.SurfaceGui.Keys
n1 = keys.n1
n2 = keys.n2
n3 = keys.n3
n4 = keys.n4
n5 = keys.n5
n6 = keys.n6
n7 = keys.n7
n8 = keys.n8
n9 = keys.n9
clear = keys.Clear
back = keys.Back
enter = keys.Enter
code = model.LDCode
i = model.Input
Lockdown = model.Lockdown
plyrinfo = Menu.SurfaceGui.Info
cardinfo = reader.SurfaceGui.Info
cardcolor = reader.SurfaceGui.Color
lvl = model.NeedLVL
divisiont = model.DIVISIONTrue
Division = model.DIVISION
HRLVL = model.HRLVL
state = model.State
local db = false 

i.Value = ""

enter.MouseButton1Down:connect(function()
    if i.Value == code.Value then
        Lockdown.Value = not Lockdown.Value
        enter.Text = "CORRECT CODE"
        wait(.75)
        enter.Text = "ENTER"
        i.Value = ""
    elseif i.Value ~= code.Value then
        enter.Text = "INCORRECT CODE"
        wait(.75)
        enter.Text = "ENTER"
        i.Value = ""    
    end
end)

n1.MouseButton1Down:connect(function() i.Value = i.Value.."1" end)
n2.MouseButton1Down:connect(function() i.Value = i.Value.."2" end)
n3.MouseButton1Down:connect(function() i.Value = i.Value.."3" end)
n4.MouseButton1Down:connect(function() i.Value = i.Value.."4" end)
n5.MouseButton1Down:connect(function() i.Value = i.Value.."5" end)
n6.MouseButton1Down:connect(function() i.Value = i.Value.."6" end)
n7.MouseButton1Down:connect(function() i.Value = i.Value.."7" end)
n8.MouseButton1Down:connect(function() i.Value = i.Value.."8" end)
n9.MouseButton1Down:connect(function() i.Value = i.Value.."9" end)
clear.MouseButton1Down:connect(function() i.Value = "" end)

back.MouseButton1Down:connect(function()
    Menu.SurfaceGui.Keys.Visible = false
    Menu.SurfaceGui.Alarm.Visible = true
    Menu.SurfaceGui.Lockdown.Visible = true
end)

Menu.SurfaceGui.Lockdown.MouseButton1Down:connect(function()
    Menu.SurfaceGui.Keys.Visible = true
    Menu.SurfaceGui.Alarm.Visible = false
    Menu.SurfaceGui.Lockdown.Visible = false
end)

reader.Touched:connect(function(thing)
    if thing.Parent.ClassName == "Tool" then return end
    if thing.Parent:findFirstChild("level") then return end
    if divisiont.Value == false then
        if (thing.Parent:findFirstChild("level").Value <= lvl.Value - 1) then
        cardcolor.BackgroundColor3=Color3.new(170,0,0)
        cardinfo.Screen.Text = "ACCES DENIED"
        wait(1)
        cardcolor.BackgroundColor3=Color3.new(117,117,117)
        cardinfo.Screen.Text = "Insert card"
        else
            if state.Value == 1 then --open
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 3 then --close
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 2 then

            end
        end
    elseif divisiont.Value == true then
        if thing.Parent:findFirstChild(Division.Value) or (thing.Parent:findFirstChild("level").Value >= HRLVL.Value) then
            if state.Value == 1 then --open
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 3 then --close
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 2 then

            end
        else
        cardcolor.BackgroundColor3=Color3.new(170,0,0)
        cardinfo.Screen.Text = "ACCES DENIED"
        wait(1)
        cardcolor.BackgroundColor3=Color3.new(117,117,117)
        cardinfo.Screen.Text = "Insert card"
        end

    end
end)

the part that isnt doing anything is

reader.Touched:connect(function(thing)
    if thing.Parent.ClassName == "Tool" then return end
    if thing.Parent:findFirstChild("level") then return end
    if divisiont.Value == false then
        if (thing.Parent:findFirstChild("level").Value <= lvl.Value - 1) then
        cardcolor.BackgroundColor3=Color3.new(170,0,0)
        cardinfo.Screen.Text = "ACCES DENIED"
        wait(1)
        cardcolor.BackgroundColor3=Color3.new(117,117,117)
        cardinfo.Screen.Text = "Insert card"
        else
            if state.Value == 1 then --open
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 3 then --close
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 2 then

            end
        end
    elseif divisiont.Value == true then
        if thing.Parent:findFirstChild(Division.Value) or (thing.Parent:findFirstChild("level").Value >= HRLVL.Value) then
            if state.Value == 1 then --open
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 3 then --close
            cardcolor.BackgroundColor3=Color3.New(0,85,0)
            cardinfo.Screen.Text = "ACCESS GRANTED"
            local namet = thing.Parent:findFirstChild("name")
            local rankt = thing.Parent:findFirstChild("rank")
            plyrinfo.name.Text = namet.Value
            plyrinfo.rank.Text = rankt.Value
            plyrinfo.level.Text = "LEVEL".. thingo.Value
            plyrinfo.Visible = true
            wait(0.25)
            cardcolor.BackgroundColor3=Color3.new(117,117,117)
            cardinfo.Screen.Text = "Insert card"
            plyrinfo.Visible = false
            plyrinfo.name.Text = ""
            plyrinfo.rank.Text = ""
            plyrinfo.level.Text = ""
            elseif state.Value == 2 then

            end
        else
        cardcolor.BackgroundColor3=Color3.new(170,0,0)
        cardinfo.Screen.Text = "ACCES DENIED"
        wait(1)
        cardcolor.BackgroundColor3=Color3.new(117,117,117)
        cardinfo.Screen.Text = "Insert card"
        end

    end
end)

does anyone know whats wrong with this script? I'm working on my own blast door and it wont work without this part (the moving of the door isnt added yet as this has to work first)

1 answer

Log in to vote
0
Answered by 9 years ago

I think because u miss spelled Denied access in lines: 87,156,076 and thats it maybe i am not that good at scripting :)

0
no, thats not it, that worked before I added the rest GreyLuca 30 — 9y
0
then take the things that u added little by little chucho88 0 — 9y
Ad

Answer this question