You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I want to make a brick that will fall when a player touches it, and after a certain amount of time re spawns.
What is the issue? Include screenshots / videos if possible!
I can’t find anything that will help me make one.
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I tried looking on youtube, but didn’t find anything on my problem. I also searched this on the devforum and I didn’t find one.
Just use a .Touched event, and then coroutine.wrap() or spawn() a function that will unanchor the brick, then return it to its previous position.
EDIT: Wait never mind I read your post a little wrong.
Either way mostly the same thing, just use a .Touched even with a debounce, and have the brick’s position saved at the beginning of the script, then just unanchored the brick and move the brick back to its saved position after you wait() a certain amount of time.
Hello there! Here is a quick script that I wrote up that you could place inside of a part, with some comments that describe what each line of code does! I will also provide the code without comments below as well.
local part = script.Parent --Variable set to original part
local debounce = false --Debounce variable
----//Detect when the part has been touched
part.Touched:Connect(function(touched)
----//Detect if touched input is a valid player and checks for debounce
if touched.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true --Debounce so that we don't trigger this function multiple times
----//Creates a fake copy of the part that falls
local copy = part:Clone()--Creates a clone of the block
copy:FindFirstChild("Script"):Remove()--Remove the script in the cloned part
----//Make the original part invisible and uncollidable, then we can work with the cloned part
part.Transparency = 1 --Turns Original Part invisible
part.CanCollide = false --Makes Original Part uncollidable
----//Work with the cloned part
copy.Parent = part.Parent --Sets cloned part parent instance to the original parts parent instance
copy.Anchored = false --Makes the clone part fall with physics
wait(10) --Time to wait for the part to come back or 'Respawn', you can change the number to the time you want in seconds
----//Destroy the cloned part and set original part back to it's state
copy:Destroy() --Destroy the cloned parts instance
part.Transparency = 0 --Turns Original Part visible
part.CanCollide = true --Makes Original Part collidable
debounce = false --Closes the debounce so that this function can be activated again
end
end)
Here is the same code but without comments in case you want to keep the script clean.
local part = script.Parent
local debounce = false
part.Touched:Connect(function(touched)
if touched.Parent:FindFirstChild("Humanoid") and debounce == false then
debounce = true
local copy = part:Clone()
copy:FindFirstChild("Script"):Remove()
part.Transparency = 1
part.CanCollide = false
copy.Parent = part.Parent
copy.Anchored = false
wait(10)
copy:Destroy()
part.Transparency = 0
part.CanCollide = true
debounce = false
end
end)
I also needed this for an obby I tried it out and it bounced me up to spawn when i fell with the block is there any reason why it did this? Also when i stepped on it the part did not fall straight down in a upward position it was like spinning downwards so like spinning on different sides while going down. Is there any fix to this?