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

Restricted door for certain players not working? Help.

Asked by
djwchon 10
3 years ago

So I have this door that I made for certain players only by using a string value. Whenever I click the handle, it does not work. Anything helps., Thanks!

local isOn = true
local d1 = script.Parent.DoorF1
local d2 = script.Parent.DoorF2
local h1 = script.Parent.Handle1
local h2 = script.Parent.Handle2
local g1 = script.Parent.Glass1
local g2 = script.Parent.Glass2

function on()
    isOn = true
    g1.CanCollide = true
    g1.Transparency = 0.5
    h1.Transparency = 0
    g2.CanCollide = false
    g2.Transparency = 1
    h2.Transparency = 1
    d1.CanCollide = false
    d1.Transparency = 0
    h1.Transparency = 0
    d2.CanCollide = false
    d2.Transparency = 1
    h2.Transparency = 1
    script.Parent.Owner.SurfaceGui.Enabled = false
    h1.CanCollide = false
    h2.CanCollide = false
    script.Parent.Owner.SurfaceGui.Enabled = true
end
function off()
    isOn = false
    g1.CanCollide = false
    g1.Transparency = 1 
    h1.Transparency = 1
    g2.CanCollide = true
    g2.Transparency = 0.5
    h2.Transparency = 0
    h1.CanCollide = false
    d1.CanCollide = false
    d1.Transparency = 1 
    h1.Transparency = 1
    d2.CanCollide = false
    d2.Transparency = 0
    script.Parent.Owner.SurfaceGui.Enabled = false
    wait(1.8)
    g1.CanCollide = true
    g1.Transparency = 0.5
    h1.Transparency = 0
    g2.CanCollide = false
    g2.Transparency = 1
    h2.Transparency = 1
    h1.CanCollide = false
    d1.CanCollide = false
    d1.Transparency = 0
    h1.Transparency = 0
    d2.CanCollide = false
    d2.Transparency = 1
    h2.Transparency = 1
    h1.CanCollide = false
    script.Parent.Owner.SurfaceGui.Enabled = true
    script.Parent.Handle2.Close:Play()
end

function onClicked()
    if script.Parent.IsRestricted.Value == Instance.Name then
        if isOn == true then off() else off() end
        script.Parent.Handle1.Open:Play()
        script.Parent.Handle1.Click:Play()
        if isOn == true then off() else off()end
    elseif script.Parent.IsRestricted.Value ~= Instance.Name then
        script.Parent.Handle1.Locked:Play()
        if isOn == true then on() end
    end

end

script.Parent.Handle1.ClickDetector.MouseClick:connect(onClicked)

on()


0
Try printing. Soban06 410 — 3y
0
could you elaborate on that? I'm new to scripting djwchon 10 — 3y
0
Use Print("checkpoint 1!") or something as an example for debugging bromy_dad 0 — 3y

Answer this question