[HELP] Send Variable from Server to Client | TriggerClientEvent not working

I feel you man, Anyway

Threads are simple thing(if you need help with understanding something in lua other than this discussion then dm me). Here is the Client-side code

local clientRandom = 0

TriggerServerEvent('ServerRdm')

RegisterNetEvent('ServerRdm') -- register once and it will work just fine
AddEventHandler('ServerRdm', function(serverRandom)
        clientRandom = serverRandom -- overriding local clientRandom
        print(clientRandom, serverRandom) -- same thing
end)

print(clientRandom) -- will return 0
CreateThread(function()
        print(clientRandom) -- will return 0
        print(serverRandom) -- will return nil
        Wait(500) -- delay between execution
        print(clientRandom) -- will return value from server-side
end)
2 Likes