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

Why does this not change the part's attributes when a certain message is chatted?

Asked by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg == ":open" then
            game.Part.Transparency = 1
            game.Part.CanCollide = false
        elseif msg == ":close" then
            game.Part.Transparency = 0
            game.Part.CanCollide = true
        end
    end)
end)

There is only one object called Part in the workspace.

0
"Disconnected event because of exception" is the error I receive. dirty_catheter 7 — 10y

3 answers

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
10 years ago
game.Part

Part isn't a child of game. I think you mean

game.Workspace.Part

In Lua, you always go from broad to specific. You can't go directly from very broad to very specific, you must put the complete path to the object, starting at the broadest possible (game) and getting more and more specific until you find Part.

0
Thank you very much, I'm surprised I didn't catch that. dirty_catheter 7 — 10y
Ad
Log in to vote
0
Answered by 10 years ago
game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
        if msg :find( ":Open":lower() ) then -- hi this is bob OH yea I forgot :open *script finds the executes*
            game.Workspace.Part.Transparency = 1
            game.WorkspacePart.CanCollide = false
        elseif msg:find( ":Close":lower() ) then
           game.Workspace.Part.Transparency = 0
           game.Workspace.Part.CanCollide = true
        end
    end)
end)
Log in to vote
-7
Answered by 10 years ago

" and 1=1

1
That doesn't help me at all... dirty_catheter 7 — 10y
1
What kind of answer is that? Perci1 4988 — 10y

Answer this question