I fix it
local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local part = script.Parent
local originalPosition = part.Position
local downPosition = originalPosition - Vector3.new(0, 2, 0)
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
while true do
local ChrT = {}
for k, v in Players:GetPlayers() do
if not v.Character then continue end
table.insert(ChrT, v.Character)
end
local overlapParams = OverlapParams.new()
overlapParams.FilterType = Enum.RaycastFilterType.Whitelist
overlapParams.MaxParts = 50
overlapParams.FilterDescendantsInstances = {ChrT}
local boxPosition = part.CFrame
local boxSize = part.Size + Vector3.new(0.5,0.5,0.5)
local partT = workspace:GetPartBoundsInBox(boxPosition,boxSize, overlapParams)
local FindHRP = false
for k, v in partT do
local Chr = v.Parent
local Plr = Players:GetPlayerFromCharacter(Chr)
if Plr then
FindHRP = true
end
end
local IsTweenDown, IsTweenUp = false, false
if FindHRP then
if not IsTweenDown then
IsTweenDown = true
local tweenDown = TweenService:Create(part, tweenInfo, {Position = downPosition})
tweenDown:Play()
tweenDown.Completed:Wait()
IsTweenDown = false
end
else
if not IsTweenUp then
IsTweenUp = true
local tweenUp = TweenService:Create(part, tweenInfo, {Position = originalPosition})
tweenUp:Play()
tweenUp.Completed:Wait()
IsTweenUp = false
end
end
task.wait(0.1)
end