Server sends an event to all clients to trigger the event on the client.
Add an event object in the WorkSpace. Create a server script. It can create a part that will send an event once the part is touched by the player to display the player's name in the form of text by executing the method on the client.
local new = RWObject.Create("Part") -- create a part new.Position = Vector3.New(1,1,1) new.Parent = WorkSpace local eventobject = WorkSpace. EventObject -- find the event object in the WorkSpace new.CollisionEnter:Connect(function(plr) if plr:IsClass("Avatar") then local uid = plr.PlayerId local showname = plr.Name eventobject:FireAllClient(uid,showname) -- send an event; the parameter is the player's name end end)
Copy the following client script to the Client Preload. The script can display the player name in a UiText.
local eventobject = WorkSpace:WaitForChild("Event Object") -- wait for the event object in the WorkSpace eventobject.ClientEventCallBack:Connect(function(showname) local person = Players:GetLocalPlayer() -- retrieve the player local uipanel = RWObject.Create("UiPanel") -- create a UiPanel local uitxt = RWObject.Create("UiText") -- create a text uitxt.Parent = uipanel -- set the parent of the created text as a new UiPanel uipanel.Parent = person. GameUI -- set the parent of the UiPanel as the GameUI uitxt.Text = showname -- the text is the received player name end)