How do i end this script?

Hello, i made this script but i don’t know how to end it
here’s the script
`local door = script.Parent

door.Anchored = true

function open()

door.Transparency = 1

door.CanCollide = false

wait(2)

door.Transparency = 0

door.CanCollide = true

end

game.Players.PlayerAdded:Connect(function(p)

p.Chatted:Connect(function(msg)

    local message = msg:lower()


    if message == "t" then

        open()

end)`

anyone know how to end this script without an error?

3 Likes

i’m not sure what you mean by end (disable?, remove?) if you want to end a connected event completely You can use disconnect

What is that § doing there. You need () to specify a parameter list.

don’t you need to end a if statement with an end?

I did but for reason when i edit it it goes back to that i have specified a parameter list

Every function has an end of end to end it.

function Test()
   return print("Hello World!")
end

To make a PlayerAdded event function, simply do this:

game.Players.PlayerAdded:Connect(function(Player)
    --
end)

You just simply say end, to end a function, or if statement, or anything.

didnt i add an end to the end of the script? it looked like i did but it comes up with an error

it seems as if you are missing some ends:

game.Players.PlayerAdded:Connect(function(p)

p.Chatted:Connect(function(msg)

    local message = msg:lower()


    if message == "t" then
        open()
      end
  end)
end)

You forgot to end the if statement.

if true then

end -- ADD end on if statement

So basically it should be this:

game.Players.PlayerAdded:Connect(function(p)

p.Chatted:Connect(function(msg)

    local message = msg:lower()


    if message == "t" then

        open()

    end

end) -- End!
end) -- You need to END every function you make

^ with the function open() too

2 Likes

Thank you
(30charsssssssssssssss)

1 Like

Thanks to all who helped

1 Like

That’s an if statement, not a boolean. A boolean is simply true or false.

3 Likes

Sorry, I thought if statements were booleans but it was all just a misconception in my brain… Thanks for telling me…

1 Like