Streak Reward System

So basically everytime a player reaches a specific streak, they get rewarded with a tool.

I would appreciate any help.
Thanks

1 Like

Wrote some pseudo-code to point you in the general direction

if playerStreak == requiredStreak then
   reward(player)
end

Couldn’t get it to work. (30))

I would do something like this:

streakRewards = {
  -- [Streak number] = tool
  [5] = tool
}

game.Players.PlayerAdded:Connect(function(player)
  player.Streak.Changed:Connect(function()  -- Detect when the players streak changes
    if streakRewards[player.Streak.Value] then  -- Check if the current streak value has a tool set to it.
      streakRewards[player.Streak.Value]:Clone().Parent = player.Backpack  -- Clone the tool to the players backpack
    end

  end)
end)
1 Like

Hello, thank you for responding. But i get an error with the script

here is my script

1 Like

could you send the code, so I can edit?

game.Players.PlayerAdded:connect(function(player)
local stats = Instance.new(“IntValue”)
stats.Name = “leaderstats”
stats.Parent = player

local Streak = Instance.new(“IntValue”)
Streak.Name = “Streak”
Streak.Value = 5
Streak.Parent = stats

end)

–Datastore Script:

streakRewards = {
– [Streak number] = tool
[5] = game.ServerStorage.streaktest.Crowbar
}
game.Players.PlayerAdded:connect(function(player)

player.leaderstats.Streak.Changed:Connect(function() – Detect when the players streak changes
if streakRewards[player.leaderstats.Streak.Value] then – Check if the current streak value has a tool set to it.
streakRewards[player.leaderstats.Streak.Value]:Clone().Parent = player.Backpack – Clone the tool to the players backpack
end

end)
end)

1 Like

add a wait for child or put the code into the same connect function:
an example of the wait for child would be:

player:WaitForChild("leaderstats").Streak.Changed:Connect()

either that or combine them like so:

local streakRewards = {
– [Streak number] = tool
[5] = game.ServerStorage.streaktest.Crowbar
}

game.Players.PlayerAdded:Connect(function(player)
  local stats = Instance.new("IntValue")
  stats.Name = "leaderstats"
  stats.Parent = player

  local Streak = Instance.new(“IntValue”)
  Streak.Name = “Streak”
  Streak.Value = 5
  Streak.Parent = stats

  Streak.Changed:Connect(function() -- Detect when the players streak changes
    if streakRewards[Streak.Value] then -- Check if the current streak value has a tool set to it.
      streakRewards[Streak.Value]:Clone().Parent = player.Backpack -- Clone the tool to the players backpack
    end

  end)
end)
1 Like
local streakRewards = {
    [5] = game.ServerStorage.streaktest.Crowbar
}

game.Players.PlayerAdded:Connect(function(player)
    local stats = Instance.new(“IntValue”)
    stats.Name = “leaderstats”
    stats.Parent = player

    local Streak = Instance.new(“IntValue”)
    Streak.Name = “Streak”
    Streak.Value = 5
    Streak.Parent = stats

    Streak.Changed:Connect(function()
        if streakRewards[player.leaderstats.Streak.Value] then
            streakRewards[player.leaderstats.Streak.Value]:Clone().Parent = player.Backpack
        end
    end)
end)

why make a separate PlayerAdded event for no reason

Thank you so much, how do make the streak change when i get a kill?

That would really depend on what gun system you are using.

FE gun kit and FE melee kit. .

FE gun kit is a very vague title, searching that on google brings up every single gun kit every made but I can give you a basis.

In the script that deals damage just detect when a player is killed and add to their streak I guess.

This is the kit im using.

Im not sure how id make that work.

I had a look but I am not sure how to do it so I can be unfortunately no help to you.

Alright, Thank you for responding.