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

Whats wrong with this door?

Asked by
mkjp87 0
9 years ago

The output says" Workspace.Door.Script2:3: attempt to call method 'Touched' (a userdata value)" I don't know what I'm doing wrong

door = game.Workspace.Door
if game.Workspace.Door.Touched() then 


    door.CanCollide = false
        for i = 0.5, 1, 0.1 do
            door.Transparency = i
            wait ()
        end

        for i = 1, 0.5, -.1 do
            door.Transparency = i
            wait ()
        end
        door.CanCollide = true


end

1 answer

Log in to vote
0
Answered by
Dominical 215 Moderation Voter
9 years ago

The Touched event can be called on with a function not an if statement. Use this instead:

door = game.Workspace.Door

door.Touched:connect(function()
    door.CanCollide = false
        for i = 0.5, 1, 0.1 do
            door.Transparency = i
            wait ()
        end

        for i = 1, 0.5, -.1 do
            door.Transparency = i
            wait ()
        end
        door.CanCollide = true


end)
Ad

Answer this question