Hello, i’m making a system for a platform go down but I have one problem.
When the platform go to the floor 21, the tween service doesn’t work for the line 75. The script:
local TweenService = game:GetService("TweenService")
local foodFolder = workspace:WaitForChild("FoodSystem")
local platformFolder = foodFolder:WaitForChild("Platform")
local goalsFolder = foodFolder:WaitForChild("GoalPlatform")
local floor = 0
local touchDead = false
local oldObjects = foodFolder.Elements:Clone()
oldObjects.Parent = foodFolder
oldObjects.Name = "OldElements"
for key, objects in pairs(oldObjects:GetChildren()) do
if objects:IsA("BasePart") then
objects.Transparency = 1
objects.Anchored = false
for key, prox in pairs(objects:GetDescendants()) do
if prox:IsA("ProximityPrompt") then
prox:Destroy()
elseif prox:IsA("Script") then
prox:Destroy()
elseif prox:IsA("Sound") then
prox:Destroy()
end
end
end
end
platformFolder.Platform.Touched:Connect(function(hit)
if touchDead == false then return end
local checkHum = hit.Parent:FindFirstChild("Humanoid")
if checkHum then
checkHum:TakeDamage(math.huge)
end
end)
while wait(5.2) do
touchDead = false
floor += 1
print(floor)
if floor == 1 then
game.ReplicatedStorage.FoodSystem.RegenFood:Fire()
end
if floor > 33 then
floor = 0
end
if floor == 0 then
touchDead = true
local killPartsDetect = platformFolder.Platform:GetTouchingParts()
for key, objects in pairs(killPartsDetect) do
local check = oldObjects.Parent:FindFirstChild("Humanoid")
if check then
check:TakeDamage(math.huge)
end
end
TweenService:Create(platformFolder.Platform, TweenInfo.new(5), {Position = goalsFolder.Goal0.Position}):Play()
for key, realObjects in pairs(foodFolder.Elements:GetChildren()) do
if realObjects:IsA("BasePart") then
local check = oldObjects:FindFirstChild(realObjects.Name)
if check then
TweenService:Create(realObjects, TweenInfo.new(5), {Position = check.Position}):Play()
else
print("error, object can't be find")
end
end
end
else
local actual = "Goal"..floor
for key, objects in pairs(foodFolder.Elements:GetChildren()) do
print("checked")
TweenService:Create(objects, TweenInfo.new(5), {Position = objects.Position - Vector3.new(0,20,0)}):Play() -- line 75
end
TweenService:Create(platformFolder.Platform, TweenInfo.new(5), {Position = goalsFolder[actual].Position}):Play()
end
end