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

Enemy wont open door on touch?

Asked by 3 years ago

I've got a simple click detector door. What I want to happen is that on contact with the "enemy" the door will activate and open. Currently when I run the script it does nothing and has no error message appear in the output. Any advice on how to fix this is appreciated! Here's the code that's located in a model with three other parts inside. The door part has a clickdetector, two boolvalues inside that are named "Open" and "Close", and one sound.

local door = script.Parent.Door
local FRef = script.Parent.FRef
local FRef2 = script.Parent.FRef2

local debounce = false
script.Parent.door.Touched:connect(function(p)
    if debounce == true then return end
    debounce = true
    if door.Close.Value == true and p.Parent.Name == "Enemy" then
        script.Parent.Door.Audio2:Play()
        door.CFrame = FRef2.CFrame
        door.Orientation = Vector3.new(0, 0, 0)
        door.Close.Value = false
        door.Open.Value = true

    else if door.Open.Value == true and p.Parent.Name == "Enemy" then
            script.Parent.Door.Audio2:Play()
            door.CFrame = FRef.CFrame
            door.Orientation = Vector3.new(0, -90, 0)
            door.Close.Value = true
            door.Open.Value = false
        end
    end
    wait(3)
    debounce = false
end)
0
Is your enemy named Enemy? xXLegendGamerz16Xx 231 — 3y
0
yup it is Coneyard 23 — 3y

Answer this question