I just need a script that will reset their "streak" leaderstat if they die. I do not have any sample script cause im t r a s h at scripting, so Any Help is very much Appreciated!
A general tip I like to give people that are new to programming/coding is to do a web search about their issue. Something like "how to check if a player dies roblox" would return exactly what you are looking for.
As for how to check if a player dies, you would use a Humanoid event, Humanoid.Died.
local Humanoid = Player.Character.Humanoid Humanoid.Died:Connect(function() -- Code here end)
For the leaderstats reset, you should make an attempt to figure it out. If you are having trouble though, feel free to contact me on Discord (phxntxsmic#2021) and I will be happy to help you out further.
game.Players.PlayerAdded:Connect(function(plr) plr.CharacterAdded:Connect(function(char) local humanoid = char:WaitForChild("Humanoid") local deaths = humanoid:BreakJoints() local folder = Instance.new("Folder", deaths)
folder.Name = "Streak" local stringvalue = Instance.new("NumberValue", folder) stringvalue.Value = 10 if deaths then stringvalue.Value = 0 --Add DataStore If u wanna do it permantly end end)
end) notify me if it doesnt work also dont copy this line**************
Erm.. I understand that you are having trouble, but please try to provide any sample or attempt. Such as your leaderstats.
Well the answer is simple, so I would wanna give you a proper explanation as well..
First we are gonna define our player service, and then listen for its PlayerAdded event. We will then proceed to create our leaderstats folder, and put it into the player object.
our leaderstats would basically be: 1) A folder named leaderstats 2) an IntValue (integer value) within the leaderstats folder.
we will then listen to the players CharacterAdded event, which keep in mind gives us the character as the first parameter, and that the humanoid will indeed be there once fired.
Finally we will listen for the humanoids Died event, and then set the streak value to 0
This would all look like this:
local playersService = game:GetService("Players") playersService.PlayerAdded:Connect(function(player) local leaderstatsFolder = Instance.new("Folder") leaderstatsFolder.Name = "leaderstats" leaderstatsFolder.Parent = player local streak = Instance.new("IntValue") streak.Name = "Streak" streak.Value = 0 streak.Parent = leaderstatsFolder player.CharacterAdded:Connect(function(character) local humanoid = character.Humanoid humanoid.Died:Connect(function() player.leaderstats.Streak.Value = 0 end) end) end)
Sorry, but where would this go?