How Can I make a Block or a Part Respawn? I am a new dev and still learning how to script. Can someone please help me?
Not going to go through the bulk explanations, explain it when we travel through the codes!
--The part should be anchored, unanchor it when needed local TargetPart = <Your part here>--We are going to have the part. local ParentWhere = nil--Set it if ParentWhere == nil then ParentWhere = TargetPart.Parent; end local WaitTime = 4--Seconds after the part vanishes. local ClonedExample = TargetPart:Clone()--We clone it for the reference, storage it in the memory. --[[Below are the statements about when should the part respawn! In my situation, I respawn it after it vanished as null. ]]-- while true do--I repeat it forever repeat wait(0.01) until TargetPart == nil TargetPart = ClonedExample:Clone()--The cloned respawn part. TargetPart.Parent = ParentWhere end
Now, we make it as a method.
--The part should be anchored, unanchor it when needed local TargetPart = <Your part here>--We are going to have the part. local ParentWhere = nil--Set it if ParentWhere == nil then ParentWhere = TargetPart.Parent; end local WaitTime = 4--Seconds after the part vanishes. local ClonedExample = TargetPart:Clone()--We clone it for the reference, storage it in the memory. --METHOD local function RespawnIt() TargetPart = ClonedExample:Clone()--The cloned respawn part. TargetPart.Parent = ParentWhere end --END METHOD --[[Below are the statements about when should the part respawn! In my situation, I respawn it after it vanished as null. ]]-- while true do--I repeat it forever repeat wait(0.01) until TargetPart == nil RespawnIt() end