Issue with code

So, I just started to learn Lua, and I made a simple code. I ran into this issue. I don’t get any error messages, but I really don’t know if I typed something wrong. I’m trying to make it, so when I type in chat “Open”, doors with the name “Part2” Will open. But it just doesn’t want to work.

Here is the code:

12232

3 Likes

I suggest using this to help you do this.

One of the main ways to becoming good at scripting, is to not take a wild guess on what something is, the type is not used for what you thought it was intended, type returns the type of a value, if you had a string "good" and you did type("good") it would return string. And game.Players.BubbleChat isn’t something that exists inside of game.Players. The way to become good, is to actually search online for solutions, and for ways to conquer obstacles. You could’ve googled “how to check if player chatted something”, and as @m3o0n suggested, the .Chatted event would show up. This event will fire when the player chats something, and it would give back a parameter containing the message the user wrote in the chat. Since this event is a member of the local player, you need to reference the local player inside of a local script, and not a server script (the normal one), don’t fall for this common mistake, local player can only be acquired from a local script, a local script is put inside of StarterGui or StarterPlayerScripts.

local player = game.Players.LocalPlayer
local Part2 = game.Workspace.Part2 --this needs to be referenced differently, since it's no longer a child of the script

--there is not need to set the cancollide to true, beacuse it is by default

player.chatted:Connected(function(message)
     if message == "Open" then
           part2.Cancollide = false
     end
end

I suggest you learn more!

2 Likes

Okay thanks. I will try. :smile:

Yeah, i know i have to learn alot more. But thank you for explaining! :smile:

1 Like