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.
-- 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.
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.
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.
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.
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