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

How do I make a tool regenerate more than once?

Asked by 7 years ago
Edited 7 years ago

I am making a game that opens in an hour "Code Hunters" and I added quests and you find tools. Now I want to make the tools regenerate every 2 minutes after somebody takes it. It does that but only regenerates once when I want it to continuously regenerate. What is wrong with my script?

Here is my script:

local clone = script.Parent.Book:Clone(999999999999999999)
while true do wait(120)
    local g = script.Parent:findFirstChild("Book")
    if g ~= nil then

    else
        local o = clone:Clone()
        o.Parent = script.Parent
        o:MakeJoints()
    end
end 


Please help~

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Make a copy of the tool and put it in ServerStorage. Then put a normal script into the tool and do this:

--This is editied to your preferences you gave me on Roblox

local tool = script.Parent

tool.AncestryChanged:connect(function()
        local newTool = game:GetService("ServerStorage"):WaitForChild("name of tool"):Clone()
        newTool.Parent = workspace
        newTool.CFrame = CFrame.new(x, y, z)
    wait(60 * 2)
end)

Make sure the tool in server storage also contains this script or else it will only be regenerate once.

0
thank you so much! :D Goldenkings11 -11 — 7y
0
sorry for being a bother, but how do I make it where it respawns 2 minutes after a player takes the item? Goldenkings11 -11 — 7y
0
I've just edited it for you UltimateRaheem 75 — 7y
Ad

Answer this question