If you reach a certain point in the leaderboard, you get something, but that doesn't work

if you die, your leaderstats value will go up by 1. but, if you reach 10 deaths, you’re supposed to get a faster reload time, but the end) says there can’t be a bracket, and if I do remove it, it says line 4 got not “)”image

Do I need to place the script in a separate line? my script:


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

local DataStore = DataStoreService:GetDataStore("Deaths")


Players.PlayerAdded:Connect(function(player)
	
	local leaderstats = Instance.new("Folder")
	leaderstats.Name = "leaderstats"
	leaderstats.Parent = player
	
	local Deaths = Instance.new("StringValue")
	Deaths.Name = "Deaths"
	Deaths.Value = DataStore:GetAsync(player.UserId) or 0
	Deaths.Parent = leaderstats

	player.CharacterAdded:Connect(function(character)
  character:WaitForChild("Humanoid").Died:Connect(function()
    leaderstats.Deaths.Value = leaderstats.Deaths.Value + 1

	if Deaths.Value == 10 then
		game.Players.RespawnTime = 4.5
  end) -- red line below the bracket
end) 
	end)

	
	



Players.PlayerRemoving:Connect(function(Player)
	DataStore:SetAsync(Player.UserId, Player.leaderstats.Deaths.Value)
end)
1 Like

You’re missing end after that line

game.Players.RespawnTime = 4.5
1 Like

Hey, another update, the scripts aren’t working, for whatever reason.

I told it to ```print (“It worked!”) but when I reach 10, or 20, or 30, the print won’t come up in the output.

please tell me if I did anything wrong.

Try game.Players.LocalPlayer as it only is meant to go to that player.

2 Likes

LocalPlayer wont work if the script isn’t a localscript

I recommend changing

local Deaths = Instance.new("StringValue")

to

local Deaths = Instance.new("IntValue")

as you are storing integers not strings.
That will solve your problem because at the moment you are comparing strings with integers, so
“10” == 10 will return false.

An interesting fact is that you still were able to add strings with integers. In Lua “10” + 1 = 11.

3 Likes

I see. Where is the script located?