So I am basically trying to make a concert game and when the player is on stage, I want that player that when he chats, his messages show up in a GUI. Here is the script for the GUI:
local Remote = game.ReplicatedStorage:WaitForChild("UIRemote") local player = game.Players.LocalPlayer Remote.OnClientEvent:Connect(function(chat) player.PlayerGui.RappersChat.Inside.Chat.Text = chat end)
This isn't my original script. I just want it to make it so it basically shows up a GUI of a rectangle that everyone can see and it says whatever the person says. The model I used was " Rap Battles Kit" by Mlnitoon2. Please tell me where to put the edited script and if local or not. Help would be V.E.R.Y appreciated.
You can use the Player.Chatted
event which fires whenever the player chats.
Chat Script:
-- Normal Script in ServerScriptService local Players = game:GetService("Players") local ReplicatedStorage = game:GetService("ReplicatedStorage") local Remote = RemoteEvent.UIRemote Players.PlayerAdded:Connect(function(Player) -- when a player joins local OnStage = Instance.new("BoolValue", Player) OnStage.Name = "OnStage" OnStage.Value = false Player.Chatted:Connect(function(Message) -- when the player chats if OnStage.Value == true then -- if player is on stage Remote:FireAllClients(Message) end end) end)
Random Player Picker Script:
-- Normal Script inside ServerScriptService or Workspace local Players = game:GetService("Players") local StageCFrame = CFrame.new(11.667, 23.652, 95.261) local bindableEvent = Instance.new("BindableEvent") function tpRandomToStage() task.wait(5) -- task.wait() is slightly faster than wait() local allPlayers = Players:GetPlayers() -- basically :GetChildren() but only choose Players local randomNumber = Random.new(os.time()):NextInteger(1, #allPlayers) local randomPlayer = allPlayers[randomNumber] local randomCharacter = randomPlayer.Character local randomHumanoid = randomCharacter:FindFirstChildWhichIsA("Humanoid") randomPlayer.CharacterAdded:Connect(function() -- when the player respawns bindableEvent:Fire() end) Players.PlayerRemoving:Connect(function(player) -- when a player leaves if player == randomPlayer then -- if the player leaving is the same as the player on the stage bindableEvent:Fire() end end) -- PivotTo and GetPivot are both CFrame randomCharacter:PivotTo(StageCFrame) -- teleports the player randomPlayer.OnStage.Value = true -- sets the value to true task.wait(45) randomPlayer:LoadCharacter() -- respawns the player and teleports back to spawn randomPlayer.OnStage.Value = false -- sets the value to false end while true do local thread = task.spawn(tpRandomToStage) -- runs the function bindableEvent.Event:Wait() -- waits until player is done coroutine.close(thread) -- stops the function end
The script for the GUI:
-- LocalScript inside StarterGui or StarterPlayerScripts local Remote = game.ReplicatedStorage:WaitForChild("UIRemote") local player = game.Players.LocalPlayer Remote.OnClientEvent:Connect(function(chat) player:WaitForChild("PlayerGui"):WaitForChild("RappersChat").Inside.Chat.Text = chat end)