r/lua • • Oct 31 '26

Help Lua client sided

Does anyone know how to make something not client sided and show for other people on a five m server seems ai can’t figure it out or I need server resource files there’s gotta be another way

0 Upvotes

6 comments sorted by

View all comments

0

u/faustinresources 22d ago

You can't skip the server part on FiveM, but it's a small file. The usual pattern is: client asks the server, server tells everyone.

client.lua

RegisterCommand('wave', function()
    TriggerServerEvent('myres:wave')
end)

RegisterNetEvent('myres:showWave', function(src)
    -- runs for every player, do the visual thing here
    print(('player %s waved'):format(src))
end)

server.lua

RegisterNetEvent('myres:wave', function()
    TriggerClientEvent('myres:showWave', -1, source) -- -1 = all players
end)

Add both to fxmanifest (client_script / server_script) and that's it.

If it's an object or vehicle, you don't even need events: create it as a networked entity (CreateObject with isNetwork = true) and with OneSync everyone nearby sees it. For values other players should read, look up state bags (Entity(ent).state), they sync for you.