Models Are Not Positioning Properly

Hello developers, I am currently working on an object spawning system in which I am changing my models positions. However, My models are not positioning properly and glitch. Here is the bug and the part of the script that is associated with the bug.

The two models are exactly same. Basically, the second one of them positioned properly and the first one didn’t.
Ekran görüntüsü 2024-06-16 202549

-- The following code block gets called twice with the exact same parameters.
local ore1 = diamondOres.Ore1:Clone()

local orePositionModifier = Vector3.new(0, 0.7, 0)
local slotPosition = slot.Position + orePositionModifier

ore1:MoveTo(slotPosition)

NOTE: The slot modifier does not solve the bug when it is changed.

1 Like

If i understand correctly, the ore on the left should be in the ground?

local orePositionModifier = Vector3.new(0, 0.7, 0)

This is raising the ore, you would want -0.7 instead of 0.7

Yes, it should be in the ground. However, the position of the slot is already in the ground and I have to modify it up to make sure the diamond looks nice. The main issue is, the ore sometimes clips through the slot and moves up too much.

Can I see a screenshot of where the slot is vs where the diamond ends up

The slot is the colored ground. There are 2 different colors. (only the brick color differs.)

Are you sure it isn’t the orePositionModifiter causing it to go out of the ground? try removing it and see if it works properly

if I delete it, this happens.

Wait the darker one was the issue, please clarify

are you trying to make the darker one be the same as the lighter one?

Yes, I am trying to make the left one go into the ground. However, in this photo the modifier is deleted and the right one is too deep in the ground. To clarify, the issue is the left part that is staying at the top of the slot and not in the ground.

I see a third ore, is it working for that one too or just specifically the left one?

Actually, I have lots of slots. Some of these slots are working properly like the right one. However, some of them do not like the left one. I don’t think any factor about the slot is causing the bug because they are duplicates.

Is the code you provided in the original post the full script or is there more

It is the associated part. I can put some more code blocks about placement too but since there are 3 different scripts included I can’t put all of them. Here is the full placement function:

function module.PlaceOres(slot)
	print("module ran")
	
	local targetOreType = slot:GetAttribute("OreType")
	local ore1
	local ore2
	local ore3
	
	
	local orePositionModifier = Vector3.new(0, 0.7, 0)
	local slotPosition = slot.Position + orePositionModifier
	
	
	if targetOreType == "diamond" then
		
		
		ore1 = diamondOres.Ore1:Clone()
		ore2 = diamondOres.Ore2:Clone()
		ore3 = diamondOres.Ore3:Clone()
		
	elseif targetOreType == "gold" then
		
		ore1 = goldOres.Ore1:Clone()
		ore2 = goldOres.Ore2:Clone()
		ore3 = goldOres.Ore3:Clone()
		
	elseif targetOreType == "emerald" then
		
		ore1 = emeraldOres.Ore1:Clone()
		ore2 = emeraldOres.Ore2:Clone()
		ore3 = emeraldOres.Ore3:Clone()
		
		
	elseif targetOreType == "ruby" then
		
		ore1 = rubyOres.Ore1:Clone()
		ore2 = rubyOres.Ore2:Clone()
		ore3 = rubyOres.Ore3:Clone()
		
		
	end
	
	
	ore1.Parent = slot
	ore1:MoveTo(slotPosition)
	slot:SetAttribute("OreLevel", 1)
	
	wait(oreHoldDuration)
	
	
	ore2.Parent = slot
	ore1:Destroy()
	ore2:MoveTo(slotPosition)
	slot:SetAttribute("OreLevel", 2)
	
	wait(oreHoldDuration)
	
	
	ore3.Parent = slot
	ore2:Destroy()
	ore3:MoveTo(slotPosition)
	slot:SetAttribute("OreLevel", 3)
	
	
	
end

I have no idea what is causing this, try replacing all the slots and see it that works

As we tried to solve the problem, our 3D modeler decided to bysect the bottom parts of the model. Now, everything works fine.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.