local RandomPart = script.Parent.Lv2St3:GetChildren()
RandomPart.Touched:Connect(function(hit)
local part = RandomPart.Touched
local function NewTran(Number)
part.Transparency = Number
end
part.CanCollide = false
NewTran(0.2)
wait(1)
NewTran(0.5)
wait(1)
NewTran(1)
wait(1)
part.CanCollide = true
NewTran(0)
end)
I’d recommend you look into tweens so that the transparency portion is a lot more smoother. Secondly, you should check to see if the part is the player so that you know it’s 100% the player. You can do so by using the following function:
local partsFolder = script.Parent.Lv2St3
for Index, Item in pairs (partsFolder:GetChildren()) do
Item.Touched:Connect(function()
local part = Item.Touched
local function NewTran(Number)
part.Transparency = Number
end
part.CanCollide = false
NewTran(0.2)
wait(1)
NewTran(0.5)
wait(1)
NewTran(1)
wait(1)
part.CanCollide = true
NewTran(0)
end)
end
You can tween Transparency? I thought you could only tween size and position…
local RandomPart = script.Parent.Lv2St3:GetChildren()
for i, v in pairs(RandomPart) do
v.Touched:Connect(function(hit)
local function NewTran(Number)
v.Transparency = Number
end
v.CanCollide = false
NewTran(0.2)
wait(1)
NewTran(0.5)
wait(1)
NewTran(1)
wait(1)
v.CanCollide = true
NewTran(0)
end)
end
local partsFolder = script.Parent.Lv2St3
local tweenService = game:GetService("TweenService")
local function returnTween(transparency)
local a = TweenInfo.new(
3
)
local b = tweenService:Create(v, a, {Transparency = transparency})
return b
end
for i, v in pairs(partsFolder:GetChildren()) do
v.Touched:Connect(function()
v.CanCollide = false
local b = returnTween(1)
b:Play()
b.Completed:Wait()
wait(1)
b.CanCollide = true
v.Transparency = 1
end)
end
no.
if he add onto there then eventually it will look like my old spaghetti code
i personally prefer to have a bunch of functions instead of one long string of code
also it is not required to fill out all the arguments in tweeninfo