I was making a training panel where it says on a GUI the host / co-hosts name after pressing a button, I’ve tried many ways and I don’t know what to do next, any suggestions would be appreciated.
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function(plra)
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: "
elseif script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Host.Text
end
end)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.MouseButton1Click:Connect(function(plre)
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: "
elseif script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Cohost.Text
end
end)
Testing that now! [30 chazrrrrrr]
ignore that do this:
local plr = game.Players.LocalPlayer
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function()
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: "
elseif script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Host.Text
end
end)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.MouseButton1Click:Connect(function()
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: "
elseif script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Cohost.Text
end
end)
1 Like
I have that already, haha, and it just says the local players name instead of my name.
Here’s the full script. ^^
---
local plr = game.Players.LocalPlayer
-- buttons function of UI lol xd xd xdr wararwarrar
script.Parent.LeftTopPanel.username.Text = plr.Name
script.Parent.LeftTopPanel.rank.Text = plr:GetRoleInGroup(8176838)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function(plr)
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: "
elseif script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Host.Text
end
end)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.MouseButton1Click:Connect(function(plr)
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: "
elseif script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Cohost.Text
end
end)
-- security + opening of the UI
if plr:GetRankInGroup(8176838) >= 50 then
script.Parent.LeftTopPanel.Close_B.Visible = false
script.Parent.LeftTopPanel.Open_B.MouseButton1Click:Connect(function()
script.Parent.PanelMain.Visible = true
script.Parent.LeftTopPanel.Open_B.Visible = false
script.Parent.LeftTopPanel.Close_B.Visible = true
end)
script.Parent.LeftTopPanel.Close_B.MouseButton1Click:Connect(function()
script.Parent.PanelMain.Visible = false
script.Parent.LeftTopPanel.Open_B.Visible = true
script.Parent.LeftTopPanel.Close_B.Visible = false
end)
else
script.Parent.PanelMain.Visible = false
end
Show me that text it shows
1 Like
Do not add the plr params it will still show the players name
1 Like
It is in the players client so it will work
Example please, that would be really helpful. I’m having a hard time understanding your answer
---
local plr = game.Players.LocalPlayer
-- buttons function of UI lol xd xd xdr wararwarrar
script.Parent.LeftTopPanel.username.Text = plr.Name
script.Parent.LeftTopPanel.rank.Text = plr:GetRoleInGroup(8176838)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function()
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: "
elseif script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Host.Text
end
end)
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.MouseButton1Click:Connect(function()
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: " .. plr.Name
if script.Parent.LeftTopPanel.Title.Host.Text == "Session Host: " .. plr.Name then
warn("You cannot have multiple roles inside a training session #Error 12 ~ Rejoin if you want a different role.")
script.Parent.LeftTopPanel.Title.Cohost.Text = "Session Co-Host: "
elseif script.Parent.LeftTopPanel.Title.Cohost.Text == "Session Co-Host: " .. plr.Name then
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.Visible = false
script.Parent.PanelMain.Session_Frame.Gray_Frame.C_Host.Text = script.Parent.LeftTopPanel.Title.Cohost.Text
end
end)
-- security + opening of the UI
if plr:GetRankInGroup(8176838) >= 50 then
script.Parent.LeftTopPanel.Close_B.Visible = false
script.Parent.LeftTopPanel.Open_B.MouseButton1Click:Connect(function()
script.Parent.PanelMain.Visible = true
script.Parent.LeftTopPanel.Open_B.Visible = false
script.Parent.LeftTopPanel.Close_B.Visible = true
end)
script.Parent.LeftTopPanel.Close_B.MouseButton1Click:Connect(function()
script.Parent.PanelMain.Visible = false
script.Parent.LeftTopPanel.Open_B.Visible = true
script.Parent.LeftTopPanel.Close_B.Visible = false
end)
else
script.Parent.PanelMain.Visible = false
end
1 Like
WHat is the problem here?
1 Like
For them, it’s saying their name instead of mine.
You are supposed to press the textbutton then when it’s pressed it displays the pressers name.
Presser = person who clicked the textbutton
THen use the serevr to do it like this:
--localscript fire it in your button event
event:FireServer(gui.Text)
--serverscript
event.OnServerEvent:Connect(function(player,text)
text = player.Name
end)
1 Like
Add your textbuttons text XD
1 Like
Still doesn’t work, revolved to a different method that is saying an argument is missing.
local pla = game.Players.LocalPlayer
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function()
script.Parent.LeftTopPanel.Title.Host.Text = "Session Host: " .. game.Players:FindFirstChild(pla)
end)
Hm, If you want other people to see your name you have to use a script, not a local script because it does only show for the one who has the GUI.
Another method you can use which is more complicated is two make 2 local scripts in the GUI and 1 script in workspace or ServerScriptService using remote functions would work
but its not not recommend.
1 Like
Your problem can be solved by the use of a LocalScript, a ServerScript, and two RemoteEvents. When a client clicks the button, they will fire the “send” RemoteEvent. When the server picks up that event, the server will then fire the “receive” RemoteEvent to every client in the game, sending them the text that should update your title.
LocalScript (you’ll need two RemoteEvents in ReplicatedStorage, one named “SendEvent” and the other named “ReceiveEvent”. You’ll also need to replace the comments with the actual path to both your “title” object and your “button” object):
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local title = --Path to your title
local button = --Path to your button
local sendEvent = ReplicatedStorage:WaitForChild("SendEvent")
local receiveEvent = ReplicatedStorage:WaitForChild("ReceiveEvent")
button.MouseButton1Click:Connect(function()
sendEvent:FireServer()
end)
receiveEvent.OnClientEvent:Connect(function(text)
title.Text = text
end)
ServerScript:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.SendEvent.OnServerEvent:Connect(function(player)
ReplicatedStorage.ReceiveEvent:FireAllClients("Session Host: " .. player.Name)
end)
1 Like
This appears for the error, for the co-host one and when I press the host it does nothing
Here’s what I’ve got in Replicated Storage + Scripts.
RS:
Server Script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
ReplicatedStorage.T_Remotes.Host_Remotes.SendEvent.OnServerEvent:Connect(function(player)
ReplicatedStorage.ReceiveEvent:FireAllClients("Session Host: " .. player.Name)
end)
ReplicatedStorage.T_Remotes.Co_Remotes.SendEvent.OnServerEvent:Connect(function(player)
ReplicatedStorage.ReceiveEvent:FireAllClients("Session Co-Host: " .. player.Name)
end)
Local Script:
-- host
script.Parent.PanelMain.Session_Frame.Gray_Frame.Host.MouseButton1Click:Connect(function()
game.ReplicatedStorage.T_Remotes.Host_Remotes.Send:FireServer()
wait(0.1)
game.ReplicatedStorage.T_Remotes.Host_Remotes.Receive.OnClientEvent:Connect(function(text)
script.Parent.LeftTopPanel.Title.Host.Text = text
end)
end)
-- cohost
script.Parent.PanelMain.Session_Frame.Gray_Frame.Co_Host.MouseButton1Click:Connect(function()
game.ReplicatedStorage.T_Remotes.Co_Remotes.Send:FireServer()
wait(0.1)
game.ReplicatedStorage.T_Remotes.Co_Remotes.Receive.OnClientEvent:Connect(function(text)
script.Parent.LeftTopPanel.Title.Cohost.Text = text
end)
end)