So, I’m trying to return a part to it’s original position after tweening. I know it could be easily done by getting it’s original position first. But here’s the problem - all of the parts are different sizes, which leads to every part getting one another’s size. Is there any way I could get all of the sizes separately, then adjusting them to their proper part?
The script for more explanation:
-- Settings
local GenerationDistanceMax = 100
local GenerationDistanceMin = 70
-- Services
local TS = game:GetService("TweenService")
local SS = game:GetService("ServerStorage")
--Variables
local MapFolder = game.Workspace.Map
local SizeFound = false
local GroundPartOriginalSize = nil
local Player = game.Players.LocalPlayer
local Character = script.Parent
local Torso = Character:WaitForChild("Torso")
local GroundPartAppearTweenInfo = TweenInfo.new (
0.4, -- Length
Enum.EasingStyle.Bounce, -- Easing Style
Enum.EasingDirection.Out, -- Easing Direction
0, -- Times Repeated
true, -- Reverse
0 -- Delay
)
local GroundPartAppearTweenGoals = {Size = Vector3.new(5,5,5)}
for i, GroundPartModel in pairs (MapFolder:GetChildren()) do
if GroundPartModel:IsA("Model") then
for i, GroundPart in pairs (GroundPartModel:GetChildren()) do
if GroundPart:IsA("Part") then
GroundPartOriginalSize = GroundPart.Size
SizeFound = true
end
end
end
end
if SizeFound == true then
while wait() do
for i, GroundPartModel in pairs (MapFolder:GetChildren()) do
if GroundPartModel:IsA("Model") then
for i, GroundPart in pairs (GroundPartModel:GetChildren()) do
if GroundPart:IsA("Part") then
local GroundPartAppearTween = TS:Create(GroundPart, GroundPartAppearTweenInfo, GroundPartAppearTweenGoals)
local GroundPartDistance = Player:DistanceFromCharacter(GroundPart.Position)
if GroundPartDistance < GenerationDistanceMax then
if GroundPartDistance > GenerationDistanceMin then
GroundPart.Transparency = 0
if GroundPart.Appeared.Value == false then
GroundPartAppearTween:Play()
GroundPart.Appeared.Value = true
end
end
else
if GroundPart.Appeared.Value == true then
GroundPart.Appeared.Value = false
GroundPart.Size = Vector3.new(GroundPartOriginalSize)
end
GroundPart.Transparency = 1
end
end
end
end
end
end
end