I am trying to create a script that when a certain person enters the game an Audio and a GUI Pops up... For some reason it wont work! There is no error in script or output. So what do I do?
PersonScreen = game.StarterGui.Screen.PersonScreen Next = script.NextTime Trum = script.Trumpets function OnPlayerEntered(player) if player.userId == game.CreatorId then PersonScreen.Visible = true Next.Play() wait(7) PersonScreen.Visible = false wait(8) Next.Stop() else if player.userId == 17776158 then PersonScreen.Text = "ActuallyConnor Joined The Game!" PersonScreen.Visible = true Trum:play() wait(5) PersonScreen.Visible = false wait(20) Trum:stop() end end end
Next = script.NextTime Trum = script.Trumpets function OnPlayerEntered(player) if player.userId == game.CreatorId then for _,v in pairs (game.Players:GetPlayers()) do PersonScreen = v:WaitForChild("PlayerGui").Screen.PersonScreen PersonScreen.Text = "ActuallyConnor Joined The Game!" PersonScreen.Visible = true end Next:Play() wait(7) for _,v in pairs (game.Players:GetPlayers()) do PersonScreen = v:WaitForChild("PlayerGui").Screen.PersonScreen PersonScreen.Visible = false end wait(8) Next:Stop() else if player.userId == 17776158 then for _,v in pairs (game.Players:GetPlayers()) do PersonScreen = v:WaitForChild("PlayerGui").Screen.PersonScreen PersonScreen.Text = "ActuallyConnor Joined The Game!" PersonScreen.Visible = true end Trum:play() wait(5) for _,v in pairs (game.Players:GetPlayers()) do PersonScreen = v:WaitForChild("PlayerGui").Screen.PersonScreen PersonScreen.Visible = false end wait(20) Trum:stop() end end end game.Players.PlayerAdded:connect(OnPlayerEntered)
Basically, the for loops get each player in players and changes the gui manually.
You need to have the connect function
PersonScreen = game.StarterGui.Screen.PersonScreen Next = script.NextTime Trum = script.Trumpets function OnPlayerEntered(player) if player.userId == game.CreatorId then PersonScreen.Visible = true Next.Play() wait(7) PersonScreen.Visible = false wait(8) Next.Stop() else if player.userId == 17776158 then PersonScreen.Text = "ActuallyConnor Joined The Game!" PersonScreen.Visible = true Trum:play() wait(5) PersonScreen.Visible = false wait(20) Trum:stop() end end end game.Players.PlayerAdded:connect(OnPlayerEntered)