What I am trying to achieve?
I am currently working on a simulator game for coding practice. What I'm working on currently is having an ice cream part change size and position smoothly when the player scoops it.What is the issue?
There is an IntValue inside the ice cream part's parent that determines the size of the ice cream. How sizing works is: part.Size=Vector3.new(size.Value, size.Value/1.5, size.Value). The sizing works fine, however I don't know how to determine what Y position to change the part to for it to be lying on the ground. Is there some method or equation to find out how far down to move the part based on the change in size?What solutions have I tried so far?
Mainly just messing around with subracting and dividing based off of the original Y position and the parts size, but I can't get it to work.Here's my current code (I took out the Y position edits, as my most recent attempt did not work at all):
local model = script.Parent
local size = model.size
local part = model.part
local replicatedStorage = game:GetService("ReplicatedStorage")
local remotes = replicatedStorage.remotes
local scoop = remotes.scoop
scoop.OnServerEvent:connect(function(player, _model)
if _model == model then
size.Value = size.Value - 1
end
end)
size.Changed:connect(function()
if size.Value == 0 then
model:Destroy()
end
local position = part.Position
local goal = {Size = Vector3.new(size.Value, size.Value / 1.5, size.Value)}
local tweenInfo = TweenInfo.new(
1,
Enum.EasingStyle.Elastic,
Enum.EasingDirection.Out
)
local tween = game:GetService("TweenService"):Create(part, tweenInfo, goal)
tween:Play()
end)