try this:
addEvent("theMarkers", true)
addEventHandler("theMarkers",root,function()--there is no need for the first arguement
local Marker1 = createMarker ( math.random (1431,1613), math.random (-1046,-1029), math.random (22.5,22.906229019165), "cylinder", 3, 255, 0, 0, 255 )
local Bblip1 = createBlip ( 0, 0, 0, 56, 3 )
attachElements ( Marker1, Bblip1 ) --attach elements outside of the event
addEventHandler("onClientMarkerHit", Marker1,function(hitPlayer)
if (hitPlayer == localPlayer) then --check if the hitPlayer is localPlayer first
if isPedInVehicle ( hitPlayer ) then
local randomly = math.random ( 5, 100 ) and math.random ( 50, 500 )
givePlayerMoney ( randomly )
outputChatBox(" You've got #00ff00$"..randomly.." #ffff00from the station",255,255,0, true)
setElementPosition(Marker1,math.random (1431,1613), math.random (-1046,-1029), math.random (22.5,22.906229019165)) --set Markers Position
else
outputChatBox("you must be on your bus")
end
end
end)
end)