First off, wait() is deprecated, please use task.wait() next time
This is what I would do to make smooth disappearing and reappearing
TweenService is not only for GUI’s by the way
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local debounce = true
-- Enum.EasingStyle and Enum.EasingDirection are optional
local DisappearTweeningInfo = TweenInfo.new(--[[how long it takes to disappear]])
local AppearTweeningInfo = TweenInfo.new(--[[how long it takes to reappear]])
-- Using Goals allows you to edit more than 1 property of an object at a time!
--[[ Quick Example of Goals
local Goal = {}
Goal.Transparency = 0
Goal.Position = Vector3.new(10, 10, 10)
]]
local DisappearGoal = {}
DisappearGoal.Transparency = 1
local AppearGoal = {}
AppearGoal.Transparency = 0
Part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid and debounce == true then
debounce = false
TweenService:Create(Part, DisappearTweeningInfo, DisappearGoal):Play()
Part.CanCollide = false
task.wait(8)
TweenService:Create(Part, AppearTweeningInfo, AppearGoal):Play()
Part.CanCollide = true
debounce = true
end
end)
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local debounce = true
-- Enum.EasingStyle and Enum.EasingDirection are optional
local DisapearTweeningInfo = TweenInfo.new(0.2)
local AppearTweeningInfo = TweenInfo.new(8)
-- Using Goals allows you to edit more than 1 property of an object at a time!
--[[ Quick Example of Goals
local Goal = {}
Goal.Transparency = 0
Goal.Position = Vector3.new(10, 10, 10)
]]
local DisappearGoal = {}
DisappearGoal.Transparency = 1
local AppearGoal = {}
AppearGoal.Transparency = 0
Part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid and debounce == true then
debounce = false
TweenService:Create(Part, DisappearTweeningInfo, DisappearGoal):Play()
Part.CanCollide = false
task.wait(8)
TweenService:Create(Part, AppearTweeningInfo, AppearGoal):Play()
Part.CanCollide = true
debounce = true
end
end)
DisappearTweeningInfo
seems to be underlined in red, and the smooth disappear/appear doesn’t work
This should work, check for typos (just in case lol)
local TweenService = game:GetService("TweenService")
local Part = script.Parent
local debounce = true
-- Enum.EasingStyle and Enum.EasingDirection are optional
local DisappearTweeningInfo = TweenInfo.new(--[[how long it takes to disappear]])
local AppearTweeningInfo = TweenInfo.new(--[[how long it takes to reappear]])
-- Using Goals allows you to edit more than 1 property of an object at a time!
--[[ Quick Example of Goals
local Goal = {}
Goal.Transparency = 0
Goal.Position = Vector3.new(10, 10, 10)
]]
local DisappearGoal = {}
DisappearGoal.Transparency = 1
local AppearGoal = {}
AppearGoal.Transparency = 0
Part.Touched:Connect(function(hit)
local humanoid = hit.Parent:FindFirstChildWhichIsA("Humanoid")
if humanoid and debounce == true then
debounce = false
TweenService:Create(Part, DisappearTweeningInfo, DisappearGoal):Play()
Part.CanCollide = false
task.wait(8)
TweenService:Create(Part, AppearTweeningInfo, AppearGoal):Play()
Part.CanCollide = true
debounce = true
end
end)