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

Why does when run my script to move a multiple part door fail with no errors?

Asked by
Zikelah 20
4 years ago
Edited 4 years ago

I have a door that when the sensor is touched it makes the door go to a certain position. I have some pictures for the scene:

where the parts are located: https://gyazo.com/9737b50291116f8ea83e228a2dfb925e

The GIF of everything: https://gyazo.com/9737b50291116f8ea83e228a2dfb925e there are no errors when run, so what went wrong, oh the script itself:

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 function MoveTheDoor(Part)
    local hum = script.Parent.Parent.Parent.Parent:FindFirstChild("Humanoid")
    if hum then
        if db then
            me.Anchored = false
            Light.Anchored = false
            Window.Anchored = false
            db = false
            Light.BrickColor = "Lime Green"
            me.Position = Vector3.new(186.908, 6.31, 566.196)
            wait()
            me.Anchored = true
            Light.Anchored = true
            Window.Anchored = true
            wait(4)
            me.Anchored = false
            Light.Anchored = false
            Window.Anchored = false
            wait()
            me.Position = Vector3.new(188.325, 6.31, 562.949)
            Light.BrickColor = "Really Red"
            wait()
            me.Anchored = true
            Light.Anchored = true
            Window.Anchored = true
            wait(.5)
            db = true
        end
    end

end

sensor.Touched:Connect(MoveTheDoor)

there is the script. San anyone find the answer to my problems?

1 answer

Log in to vote
0
Answered by
Prestory 1395 Moderation Voter
4 years ago
Edited 4 years ago

The hum variable is incorrect it is actually hit.Parent that contains the humanoid this is how you define the humanoid in a touch function

local me = script.Parent.Parent
local Light = script.Parent.Parent.Light
local db = true
local sensor = script.Parent
local Window = script.Parent.Parent.Window

function MoveTheDoor(hit)
    print('Running')
    local hum = hit.Parent:FindFirstChild('Humanoid')
    print('1')
    if hum then
    print('2')
        if db then
            me.Anchored = false
            Light.Anchored = false
            Window.Anchored = false
            db = false
            Light.BrickColor = "Lime Green"
            me.Position = Vector3.new(186.908, 6.31, 566.196)
            wait()
            me.Anchored = true
            Light.Anchored = true
            Window.Anchored = true
            wait(4)
            me.Anchored = false
            Light.Anchored = false
            Window.Anchored = false
            wait()
            me.Position = Vector3.new(188.325, 6.31, 562.949)
            Light.BrickColor = "Really Red"
            wait()
            me.Anchored = true
            Light.Anchored = true
            Window.Anchored = true
            wait(.5)
            db = true
        end
    end

end

sensor.Touched:Connect(MoveTheDoor)
Ad

Answer this question