MoveObj = function()
while true do
if IsButtonBeingPressed(2, 0) then
Wait(100)
Heading = PedGetHeading(gPlayer)
Rotation = math.deg(Heading)
DeltaX = -math.sin(Heading)
DeltaY = math.cos(Heading)
gPX, gPY, gPZ = PedGetPosXYZ(gPlayer)
FrontObjects = {ObjectFindInArea(gPX + DeltaX, gPY + DeltaY, gPZ + 0.3, 0.3)}
FrontObject = FrontObjects[1]
ObjectBreak(FrontObject)
PEIndex, PE = CreatePersistentEntity(FrontObject, HX + DeltaX, HY + DeltaY, HZ - 0.5, Rotation, AreaGetVisible())
repeat
DeletePersistentEntity(PEIndex, PE)
Heading = PedGetHeading(gPlayer)
Rotation = math.deg(Heading)
DeltaX = -math.sin(Heading)
DeltaY = math.cos(Heading)
gPX, gPY, gPZ = PedGetPosXYZ(gPlayer)
PEIndex, PE = CreatePersistentEntity(FrontObject, gPX + DeltaX, gPY + DeltaY, gPZ + 0.3, Rotation, AreaGetVisible())
if IsButtonBeingPressed(2, 0) then
break
end
Wait(0)
until IsButtonBeingPressed(2, 0)
end
Wait(0)
end
end
When I press aim button, game crash