Hello!
I was wondering if anyone is familiar with the collection service and help me out with this bug. I am trying to create a part where if a player touches it, it slowly falls down using tween service. I wrote the code in a local script so it only happens for that player, but then I came a cross a bug where it tweens for other players as well even if they are not touching it. I looked at the server view and it’s not tweeting there; just other clients.
Your help is much appreciated!
Code:
local TweenService = game:GetService("TweenService")
local CollectionService = game:GetService("CollectionService")
local GetParts = CollectionService:GetTagged("Falling")
for _, v in pairs(GetParts) do
local TweenInfo1 = TweenInfo.new(
v:GetAttribute("Duration"), --3
Enum.EasingStyle.Linear,
Enum.EasingDirection.InOut,
0,
false,
0
)
local TweenGoals1 = {
Position = v.Position + Vector3.new(0,-5,0),
Transparency = 1
}
local TweenGoals2 = {
Transparency = 1
}
local Tween1 = TweenService:Create(v,TweenInfo1,TweenGoals1)
local Tween2 = TweenService:Create(v.Decal,TweenInfo1,TweenGoals2)
v.Touched:Connect(function(hit)
local Humanoid = hit.Parent:FindFirstChild("Humanoid")
if Humanoid then
coroutine.resume(coroutine.create(function()
local OrigPos = v.Position
Tween1:Play()
Tween2:Play()
Tween1.Completed:Connect(function()
v.CanCollide = false
wait(v:GetAttribute("Duration"))
v.CanCollide = true
v.Position = OrigPos
v.Transparency = 0
v.Decal.Transparency = 0.5
end)
end))
end
end)
end