Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a part disappear after a while?

Asked by 4 years ago

Hi! I started developing a game recently on Roblox Studio, and towards the end of my game development I had a certain problem, I would have to be teleported to a room after a long labyrinth, and this hall is supposed to hold a monster in the same location for at least 10 seconds. And to hold it back, I thought that a simple wall would be enough, but here I am: How to trigger a countdown when I move into the room, and that at the end of this last (the countdown) The wall (invisible) disappears?

(I'm french, i used google traduction, so if something look to you strange, pls tell me ;w;)

0
You can do part.Transparency and a for loop. Dovydas1118 1495 — 4y

2 answers

Log in to vote
0
Answered by 4 years ago

One good solution would be to tween the door's transparency, and make it collidable. Assuming you want the countdown to start once the player enters the room

--Create a part that the player HAS to walk through to get into the room, make this part's transparency = 1, and cancollide = false
local EntrancePart = workspace.EntrancePart -- Change to the part that you created to enter the room
local MonsterWall = workspace.MonsterWall -- Change to the part that holds the monster back Make this part's transparency = 0
local TweenService = game:GetService("TweenService") -- Tween service is a great service to use to smoothly change many things, including what we need and thats transparency and cancollide.
EntrancePart.Touched:Connect(function(hit) -- Detect when entrance part is touched
    if game.Players:FindFirstChild(hit.Parent.Name) or game.Players:FindFirstChild(hit.Parent.Parent.Name) then -- Make sure a player touched it to prevent premature fire
        local goal = {} -- Create tweenservice's goal for transparency and cancollide
        goal.Transparency = 1
        goal.CanCollide = false

        local tweenInfo = TweenInfo.new(10) -- Change 10 to how long you want it to take( in seconds)

        local tween = TweenService:Create(MonsterWall, tweenInfo, goal) -- Create the tween

        tween:Play() -- Play the tween
    end
end)
--What happens is a player enters the room, and triggers the Entrance Part's function. It's function will check to make sure that it was a player that touched it, and if so it will begin a 10 second tween. During the tween the part will slowly turn invisible, and once the tween is finished the part will become non collidable.

Ad
Log in to vote
0
Answered by 4 years ago

Thank you very much for your help!!! I almost finished my game now! I hope my request wasn't too hard ;w; and that i don't make you lose your time. Have a nice day!

Answer this question