Help with moving part

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
1 Like

thank you its working good as i want it, now i will research your code to understand what you did.

1 Like

@Scottifly @BOOC2002 @Davidof123321 @Wigglyaa @Diamond_Boiiiiiiii

i want to thank you for trying to help me. i finally found a solution. i appreciate all of you <3

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.