Get data from server to client! Help me!

Hi guys,

I would like to ask for your help with this problem “Get data from server to client”

Ex:

Server

TriggerClientEvent(‘event’, -1, ‘Hello World!’)

Client

RegisterNetEvent(‘event’)
AddEventHandler(‘event’, function(str)
String = str
end)

Print(String) —this is problem <————

I want to ‘print string’, how do I do it?

Thank you, guys

Does your print have a reason to be outside of the event ?

Server

TriggerClientEvent('event', -1, 'Hello World!')

Client

RegisterNetEvent('event')
AddEventHandler('event', function(str)
    local String = str
    print(String)
    -- or
    -- print(str)
end)
1 Like

Yes, i want print out side event. Can i do that?

Yes. but print is triggered while String is not defined?

Everything outside of the event is triggered when the script starts

1 Like

We are not closing this. We are going to reset the original question and you should share the solution. This forum is not just for you. People with the same issue/question need to be able to find a solution first before having to pollute the forum with another topic