ClientEventCallBack

Constructor:

ClientEventCallBack:Connect(function(...) )

Description

Client receives an event callback.

Parameter

Name Class Name Description
Tuple Passing parameter

Examples

Add an event object in the WorkSpace. 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) -- the client receives a callback
    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)

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:FireClient(uid,showname) -- send an event; the parameter is the player's name
  end
end)