How to make a Time Based tool giver

Going around on devforum/youtube and many more to find this type of topic, but I seem to find nothing but tumbleweed. Anyway, I want something like if the player has 10 minute playtime in the game it automatically gives a certain tool straight into their inventory.

1 Like

Luckily I have this on my some experiment place.

local Players = game:GetService("Players")
local PlayTime = 10 * 60 -- Seconds to Minute
Players.PlayerAdded:Connect(function(thisPlayer)
    for count = 0, PlayTime, 1 do
       if count == PlayTime then
          local Tool = --location Of The Tool
          Tool:Clone().Parent = thisPlayer.BackPack
       end
    end
end)

You can modify this into more reliable.

1 Like

Do I have to put the tool id in local Tool = (id) or It’s a parent.

1 Like

Define the path to the tool. It would be something like this (just an example)

local tool = game.ReplicatedStorage.ToolsFolder.Sword

Alright I’ll try that, thank you.

2 Likes

Also change the PlayTime to like 15 so that you don’t have to wait 10 minutes while testing.

1 Like

Which line do I change there, I see tons of numbers, I’m a bit dumb.

You will change this line:

local PlayTime = 10 * 60 -- Seconds to Minute

to

local PlayTime = 15

@Sorbious left out the wait(1), change it to this:

local Players = game:GetService("Players")
local PlayTime = 15 
Players.PlayerAdded:Connect(function(thisPlayer)
    for count = 0, PlayTime, 1 do
       wait(1)
       if count == PlayTime then
          local Tool = --location Of The Tool
          Tool:Clone().Parent = thisPlayer.BackPack
       end
    end
end)
2 Likes

I put the tool in the replicated storage, and put the script in the Workspace am I doing something wrong here?


image

What did you set the Tool variable to?

I created a new counter that is “better” than my old post

this:

local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")

local PlayTime = 600 --seconds (600/60 = 10 minutes)
local Tool = ReplicatedStorage:WaitForChild("ToolName")

Players.PlayerAdded:Connect(function(thisPlayer)
    local counter = 0
    
    while wait(1) do -- while loop will run infinite by 1 second. (for loop will stop once it reach its maximum value) or it has "break" inside.
        if counter >= PlayTime then -- Check if counter is more-than or equal to the value of PlayTime
            local newTool = Tool:Clone() -- Clone new tool
            newTool.Parent = thisPlayer.Backpack -- Set the Parent to thisPlayer || Backpack not BackPack (Sorry for my Typo there)
            
            break -- this is optional if you want to stop the while loop. if not remove this "break"
        end
        counter = counter + 1 -- iteration
    end
end)

I’ll try that, thank you so much.

1 Like

Please mark this person’s post as solution if it solved the problem. :slight_smile:

This was one year ago why are you asking them now?

I’m a bit late…
charactercharacter