How do I make the native “CreateObject” sync for all players so everyone sees what I’ve spawned?
bit of my code:
RegisterNetEvent('trashcan')
AddEventHandler('trashcan', function()
if not ( IsPedSittingInAnyVehicle( GetPlayerPed(-1) ) ) then
local vehicle = GetVehiclePedIsIn( GetPlayerPed(-1), true )
local player = GetPlayerPed(-1)
if (DoesEntityExist(player) and not IsEntityDead(player)) then
if closetotruck == true then
SetEntityAsMissionEntity(vehicle)
if DoesVehicleHaveDoor(vehicle, 5) then
SetVehicleDoorOpen(vehicle, 5, false, false)
end
RequestModel(GetHashKey("prop_bin_10a"))
Wait(100)
trashcan = CreateObject(GetHashKey("prop_bin_10a"), GetEntityCoords(GetPlayerPed(-1)))
end
end
end
end)