What do you want to achieve? | I want to be able to move and scale models depending on where/the scale of the parent object is, like how houses and other building scales and moves with plates in a game like Plates of Fate
Example:
What is the issue? | I can’t seem to find a good way to achieve this goal.
What solutions have you tried so far? | I’ve tried to seek help on youtube and developing discord servers, but none have been helpful
You could detect when the plate’s size has changed and divide it by the plate’s original size to find the scaling factor.
local plate = workspace.Plate -- part
local house = workspace.House -- model
local originalSize = plate.Size.X
plate:GetPropertyChangedSignal("Size"):Connect(function()
house.Scale = plate.Size.X / originalSize
end)
-- Function to scale and move a model
function scaleAndMoveModel(model, scaleFactor, newPosition)
-- Scale the model
for _, part in ipairs(model:GetDescendants()) do
if part:IsA("BasePart") then
part.Size = part.Size * scaleFactor
local relativePosition = part.Position - model.PrimaryPart.Position
part.Position = newPosition + relativePosition * scaleFactor
end
end
-- Move the model
local primaryPartCFrame = model.PrimaryPart.CFrame
model:SetPrimaryPartCFrame(CFrame.new(newPosition) * (primaryPartCFrame - primaryPartCFrame.p))
end
-- Example usage
local model = script.Parent -- The model you want to scale and move
local scaleFactor = Vector3.new(2, 2, 2) -- The scale factor (2x size in this example)
local newPosition = Vector3.new(0, 50, 0) -- The new position to move the model to
scaleAndMoveModel(model, scaleFactor, newPosition)
your model should have a PrimaryPart set, which is used as a reference point for scaling and moving. The scaleAndMoveModel function takes three arguments: the model to be scaled and moved, the scale factor as a Vector3 , and the new position as a Vector3 .
Is there also a way where you can scale an object to the plate’s size when it’s not at it’s original size? Sometimes the plate will already be bigger and the building will spawn at it’s original size.
Is there also a way where you can scale an object to the plate’s size when it’s not at it’s original size? Sometimes the plate will already be bigger and the building will spawn at it’s original size.