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

Why won't this on chat script show the gui after it enables it?

Asked by 4 years ago

The sound plays but the gui won't open at all. It enables in the gui but it won't show up for some reason.

function onChatted(msg, recipient, speaker) 

local source = string.lower(speaker.Name) 
msg = string.lower(msg) 

if (msg == "start") then 
game.Workspace.GameSounds.Buzzer:Play()
game.StarterGui.TeamPicker.Enabled = true
end 
end

function onPlayerEntered(newPlayer) 
newPlayer.Chatted:connect(function(msg, recipient) onChatted(msg, recipient, newPlayer) end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered) 

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

you'd want to access the speaker's PlayerGui, not the game's StarterGui.

whatever is in StarterGui is replicated to the player's PlayerGui when they join.

function onChatted(msg, recipient, speaker) 

    local source = string.lower(speaker.Name) 
    msg = string.lower(msg) 

    if (msg == "start") then 
        game.Workspace.GameSounds.Buzzer:Play()
        source.PlayerGui.TeamPicker.Enabled = true
    end 
end

function onPlayerEntered(newPlayer) 
    newPlayer.Chatted:connect(function(msg, recipient) 
        onChatted(msg, recipient, newPlayer) 
    end) 
end 

game.Players.ChildAdded:connect(onPlayerEntered) 
0
didn't work lol KronxGoat 50 — 4y
0
fixed a typo, sorry Utter_Incompetence 856 — 4y
Ad

Answer this question