I’m just trying to move a model to the place you clicked but it only moves the hitbox, not the entire model.
Scripts :
-- Module function (yes, it prints "a")
function module:moveStructure(Pos:Vector3,rotationY:number,Structure:Model,Tycoon:Folder)
if Structure == nil or not Storage.Structures:FindFirstChild(Structure.Name) or (Structure and not Structure:IsA('Model')) then return end
print('a')
Pos = Vector3.new(Pos.X,(Structure.PrimaryPart.Size.Y / 2) + 1,Pos.Z)
local list = { }
Structure.PrimaryPart.Anchored = true
for _, Part:BasePart in Structure.Build:GetDescendants() do
if Part:IsA('BasePart') then
local weld = Instance.new('WeldConstraint',Part)
weld.Part0 = Structure.PrimaryPart
weld.Part1 = Part
list[Part] = weld
Part.Anchored = false
end
end
Structure.PrimaryPart.CFrame = CFrame.new(Pos) * CFrame.fromOrientation(0,math.rad(rotationY),0)
for Part, Weld in list do
Part.Anchored = true
Weld:Destroy()
end
end
-- script that uses it (this is inside a remote event function)
local offset = Vector3.new(0,0,0)
if selectedStructure.Properties.Offset.Value then offset = Vector3.new(.5,0,.5) end
local Clone = selectedStructure:Clone()
Module:moveStructure(Hit,rotationY,Clone,Plr.tycoon.Value)
--Clone:PivotTo(CFrame.new(Hit.X,(Clone.PrimaryPart.Size.Y / 2) + 1,Hit.Z) * CFrame.fromOrientation(0,math.rad(rotationY),0) + offset)
Clone.Parent = Plr.tycoon.Value.Structures
for _, touching:BasePart in workspace:GetPartsInPart(Clone.PrimaryPart) do
if not touching:IsDescendantOf(Clone) and touching:IsDescendantOf(Plr.tycoon.Value) and touching.Name == 'Hitbox' then
Clone:Destroy()
return
end
end
Plr.leaderstats.Cash.Value -= selectedStructure.Price.Value
I also tried looking at the devforum, but all of them said something like
The primary part should be anchored while all the others should not be anchored.
which is what I am already doing.