I have a script that allows a player to click on an object and then receive the clone of that object from lighting. I want to make it seem like that item will "respawn" after a set amount of time. Previously I just destroyed the part but I want other players to be able to pick it up again after a cooldown but I'm not sure how to do that.
local Part = script.Parent Toolname = "SCP_LEVEL1" function boop(Player) if not Player.Backpack:FindFirstChild("SCP_LEVEL1") then local Tool = game.Lighting.SCP_LEVEL1:Clone() Tool.Parent = Player.Backpack wait (5) -- Not sure what to put here to make it invisible then visible again end end script.Parent.ClickDetector.MouseClick:connect(boop)
You would change the transparency, and since you're using a clickdetector, you'd also set the maxactivationdistance to 0, so it won't appear like you can click it while it's respawning. Lastly, you'd need a "debounce" so your event doesn't fire multiple times while it's respawning.
local Part = script.Parent db = false Toolname = "SCP_LEVEL1" function boop(Player) if not Player.Backpack:FindFirstChild("SCP_LEVEL1") and not db then db = true local Tool = game.Lighting.SCP_LEVEL1:Clone() Tool.Parent = Player.Backpack Part.Transparency = 1 Part.ClickDetector.MaxActivationDistance = 0 wait(5) Part.Transparency = 0 Part.ClickDetector.MaxActivationDistance = 12 db = false end end Part.ClickDetector.MouseClick:Connect(boop)
You can change the 12 in the MaxActivationDistance to whatever you want as well.