so I am trying to make an egg that when the player clicks it or touches it (whatever works easier) they get the egg in there backpack and the after 5 minutes the egg re-appears at the spot. Any way to make this work is welcome but I assume I could use a script that clones to backpack and makes Transparency = 1 and CanCollide = false and then wait(300) seconds and "Re-Appears" or becomes seen and able to collide. I have had difficulties trying multiple methods and would like someone with coding knowledge for help. Any help is greatly appreciated.
function onTouched(hit) local pos = script.Parent.Position if script.Parent.CanCollide == true and hit.Parent:FindFirstChild("Humanoid") and game.Players:FindFirstChild(hit.Parent.Name) then script.Parent.Transparency = 1 script.Parent.CanCollide = false local plr = game.Players:FindFirstChild(hit.Parent.Name) local place = plr.Backpack local clone = script.Parent:Clone() clone.Parent = place wait(300) script.Parent.Transparency = 0 script.Parent.CanCollide = true end end script.Parent.Touched:connect(onTouched)
This is one script that seems like it should work but didnt. Feel free to use a completely different way. All I need is an egg that can be collected and re-appears after 5 minutes.
function onTouched(hit) local Pos = script.Parent.Position local Tool = Instance.new("Tool") Tool.Name = "Egg" if script.Parent.CanCollide == true and hit.Parent:FindFirstChild("Humanoid") then local plr = game.Players[hit.Parent.Name] Tool.Parent = plr.Backpack script.Parent.CanCollide = false script.Parent.Transparency = 1 wait(60 * 5) script.Parent.Transparency = 0 script.Parent.CanCollide = true end end script.Parent.Touched:connect(onTouched)
I solved it by using a Tool spawner model which spawns tools on a block. I made its transparency 1 and out it under the egg and thats how new eggs will spawn thanks though.