-
What do you want to achieve?
I want a block to disappear once a character touches it and appear after a few seconds.
-
What is the issue?
-
What solutions have you tried so far?
I didn’t find any.
My Current Server-Script:
--Located under the part
local debounce = false
script.Parent.Touched:Connect(function(HitPart)
if not debounce then
debounce = true
if HitPart.Parent:FindFirstChild("Humanoid") then
repeat wait(0.1) script.Parent.Transparency = script.Parent.Transparency +0.1 until
script.Parent.Transparency == 1
wait(4)
repeat wait(0.1) script.Parent.Transparency = script.Parent.Transparency -0.1 until
script.Parent.Transparency == 0
wait(3)
debounce = false
end
end
end)
Any help would be appreciated.
1 Like
Hi there! Using a tween would be easier!
In order to change the duration just change the first number within TweenInfo.new()
In this instance 1 being the duration!
--Located under the part
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, 0, true, 0)
local debounce = false
local Connection
script.Parent.Touched:Connect(function(HitPart)
if HitPart.Parent:FindFirstChild("Humanoid") and not debounce then
debounce = true
local Tween = TweenService:Create(script.Parent, tweenInfo, {Transparency = 1})
Tween:Play()
Connection = Tween.Completed:Connect(function()
Connection:Disconnect()
Connection = nil
debounce = false
end)
end
end)
1 Like
Thank you, it runs smootly and perfect. 
1 Like