How would I make a "You won!" GUI come up if you had gotten the most kills in an amount of time?
Asked by
2 years ago Edited 2 years ago
So I am making a simple starter fighting game where you can buy new weapons and level up, that isn't the problem. I just can't seem to think up a script that would connect to my leaderstats within my game that actually works???
The script for my leaderstats is below:
- game.Players.PlayerAdded:Connect(function(player)
- local leaderstats = Instance.new("Folder", player)
- leaderstats.Name = "leaderstats"
- local kills = Instance.new("NumberValue", leaderstats)
- kills.Name = "Kills"
- kills.Value = 0
- local deaths = Instance.new("NumberValue", leaderstats)
- deaths.Name = "Deaths"
- deaths.Value = 0
- player.CharacterAdded:Connect(function(character)
- local humanoid = character:FindFirstChild("Humanoid")
- humanoid.Died:Connect(function(died)
- deaths.Value = deaths.Value + 1
- local tag = humanoid:FindFirstChild("creator")
- local killer = tag.Value
- if tag and killer then
- killer.leaderstats:FindFirstChild("Kills").Value = killer.leaderstats:FindFirstChild("Kills").Value + 1
- end
- end)
- end)
- end)
Anyway, thanks for reading this.