[Help] Problem with object's coords

Hello. I have a simple item that puts tent in front of the player. The problem is when I put z = z - 1.0 it doesn’t change the height at all and it’s flying in the air. I tried increasing that to - 2.0 but that still doesn’t change anything and when I put -3.0 then it’s under the floor.

client.lua

RegisterNetEvent('esx_extraitems:campfire')
AddEventHandler('esx_extraitems:campfire', function()
	local model     = {
		'prop_skid_tent_03',
		'prop_skid_tent_01'
	}
	model = model[math.random(#model)]
	local playerPed = PlayerPedId()
	local coords    = GetEntityCoords(playerPed)
	local forward   = GetEntityForwardVector(playerPed)
	local x, y, z   = table.unpack(coords + forward * 1.5)

	z = z - 2.0

	ESX.Game.SpawnObject(model, {
		x = x,
		y = y,
		z = z 
	}, function(obj)
		
		SetEntityHeading(obj, GetEntityHeading(playerPed))
		PlaceObjectOnGroundProperly(obj)

		end)

		TriggerEvent("pNotify:SendNotification", {
			layout = "bottomRight",
			text = "Rozpaliłeś ognisko",
			type = "info",
			theme = "gta",
			sounds = {
				sources = {"notification.wav"}, -- For sounds to work, you place your sound in the html folder and then add it to the files array in the __resource.lua file.
				volume = 0.2,
				conditions = {"docVisible"} -- This means it will play the sound when the notification becomes visible.
			}
			})
end)

Any help appreciated because I don’t know why it doesn’t work.

Try just putting z = 2.0

If I do that then I won’t be able to put tent basically anywhere because there are literally no places with z = 2.0. It’s gonna be always under the floor.

I’m not the best programmer but when I read the script it say z = z witch means z = -2.0 maybe it’s because os the -2.0 not sure I had to check you script .

z = z - 1.0 is very different from z = 2.0 because when you have z = 15.00 for example then if you put z = z - 1.00 it’s gonna make z = 14.00. You have the script above and it’s reading the player coordinates to define z.

I see… well then I think I can’t help you :frowning:

Thank you anyways for trying. It seems that the problem can be those objects. Some other props can change height without any problem.

@edit Or maybe not. Every static object just floats in the air :frowning: