Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do you make a specific player's chat show up in a GUI ?

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.

1 answer

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)

14 comments

0

So do you know how to make it so their chat shows up in the GUI when they are standing on a specific part btw? Becuase i want only the person on stage to have the GUI contain what they say.

0

and theres an error or sumthing that says "Infinite yield possible on 'ReplicatedStorage:WaitForChild("UIRemote")" im also not using there model i only wanted the gui thingy from it nothing else. no Main Script or anything else from them

0

It should work as what you said. Maybe you did it wrong. Should I create a simple model for you?

0

If you can, but I don't want to waste your time.

1

ok thx :thumbs_up:

1

I finally finished the model. Here it is: https://web.roblox.com/library/12326645112

0

Here is also the demo game if you wanna try it out first: https://web.roblox.com/games/12326265372

0

no way

0

web.roblox

0

holy i cant believe this thank you so much T_3MasterGamer :D

1

i have never been this happy this much so far this month but this is just the key to my game!! than you so much i love this!!

0

also don't worry about this but why do items dissapear when they get off the stage?

0

It’s because they respawned.

0

Please mark my answer as solution thanks :D

This discussion is preserved as it was. New answers, comments, and votes are closed.