Hello,
I am making a part that when you touch it slowly falls down and disappears. I wrote the code in a local script and everything worked as expected, but then I came across a problem where it would disappear for other players too. It should only disappear for that one player who touched it. I checked the server POV and it didn’t disappear for the server. I am using CollectionService to do this. Does anyone know why this is happening?
Script:
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
Thanks!