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

When run My Key card Checker gives back errors. What Happens?

Asked by
Zikelah 20
4 years ago
Edited 4 years ago

Code (For @Crazy)

Script 1

local me = script.Parent.Parent
local Light = script.Parent.Parent.Light
local db = true
local sensor = script.Parent
local Window = script.Parent.Parent.Window
local Player = game.Players.LocalPlayer
local CorrectMusic = 'rbxassetid//826129174'
local Police = game:GetService("Teams"):FindFirstChild("Police")
local BadMusic = 'rbxassetid//196904458'
KeyCard = Player.Backpack:FindFirstChild("Key Card")

function MoveTheDoor(hit)
    print('Running')
    local hum = hit.Parent:FindFirstChild('Humanoid')
    print('1')
    if hum and KeyCard then

        print('2')
        if db then
            CorrectMusic:Play()
            db = false
            Light.Color = Color3.fromRGB(0,255,0)
            me.Position = Vector3.new(10.725, 5.075, -23.451)
            Window.Position = Vector3.new(10.725, 6.475, -23.451)
            wait()
            wait(4)
            wait()
            me.Position = Vector3.new(15.875, 5.075, -24.301)
            Light.Color = Color3.fromRGB(255,0,0)
            Window.Position = Vector3.new(15.875, 6.475, -24.401)
            wait()
            me.Anchored = true
            Window.Anchored = true
            wait(.5)
            db = true
        end
    elseif hum and Player.Team == "Police" then
        if db then
           CorrectMusic:Play()
            me.Anchored = false
            Window.Anchored = false
            db = false
            Light.Color = Color3.fromRGB(0,255,0)
            me.Position = Vector3.new(10.725, 5.075, -23.451)
            Window.Position = Vector3.new(10.725, 6.475, -23.451)
            wait()
            me.Anchored = true
            Window.Anchored = true
            wait(4)
            me.Anchored = false
            Window.Anchored = false
            wait()
            me.Position = Vector3.new(15.875, 5.075, -24.301)
            Light.Color = Color3.fromRGB(255,0,0)
            Window.Position = Vector3.new(15.875, 6.475, -24.401)
            wait()
            me.Anchored = true
            Window.Anchored = true
            wait(.5)
            db = true
        end

    end

end
sensor.Touched:Connect(MoveTheDoor)

Script 2

local me = script.Parent.Parent
local Light = script.Parent.Parent.Light
local db = true
local sensor = script.Parent
local Window = script.Parent.Parent.Window
local player = game.Players.LocalPlayer
local CorrectMusic = 'rbxassetid//826129174'
local Police = game:GetService("Teams"):FindFirstChild("Police")
local BadMusic = 'rbxassetid//196904458'
KeyCard = player.Backpack:FindFirstChild("Key Card")

function MoveTheDoor(hit)
    print('Running')
    local hum = hit.Parent:FindFirstChild('Humanoid')
    print('1')
    if hum  and KeyCard then
    print('2')
        if db then
            db = false
            CorrectMusic:Play()
            Light.Color = Color3.fromRGB(0,255,0)
            me.Position = Vector3.new(26.225, 5.075, -23.4)
            Window.Position = Vector3.new(26.225, 6.475, -23.4)
            wait()
            wait(4)
            wait()
            me.Position = Vector3.new(15.875, 5.075, -24.301)
            Light.Color = Color3.fromRGB(255,0,0)
            Window.Position = Vector3.new(15.875, 6.475, -24.401)
            wait()
            wait(.5)
            db = true
        end
    elseif hum and player.Team == "Police" then
        if db then
            CorrectMusic:Play()
            Light.Color = Color3.fromRGB(0,255,0)
            me.Position = Vector3.new(26.225, 5.075, -23.4)
            Window.Position = Vector3.new(26.225, 6.475, -23.4)
            wait()
            wait(4)
            wait()
            me.Position = Vector3.new(21.125, 5.075, -24.35)
            Light.Color = Color3.fromRGB(255,0,0)
            Window.Position = Vector3.new(21.125, 6.475, -24.35)
            wait()
            wait(.5)
            db = true
        end
    else
        while(50) do
            BadMusic:Play()
        end
    end

end
sensor.Touched:Connect(MoveTheDoor)
0
What's the error? DanzLua 2879 — 4y
0
Key Card Variable Zikelah 20 — 4y

Answer this question