local Human = script.Parent:WaitForChild"Humanoid"
local Player = game.Players:GetPlayerFromCharacter(script.Parent)
Human.Died:Connect(function()
if Player then
local Krak = Player:FindFirstChild"leaderstats":FindFirstChild"Krak"
if Krak then
Krak.Value = Krak.Value - 20
end
end
local Creator = Human:FindFirstChild"creator"
if Creator and Creator.Value and
Creator.Value:FindFirstChild"leaderstats" and
Creator.Value.leaderstats:FindFirstChild"Krak" then
Creator.Value.leaderstats["Krak"].Value = Creator.Value.leaderstats["Krak"].Value + 25
end
end)
I have this script here, it's supposed to go inside of Zombie and give the player 25 dollars ("Krak" the name of the currency I'm using for my game) every time the humanoid reaches 0 health. It works for the first two times that the script runs but then it just appears to run but not yield any Krak. There is no output into the console whatsoever. I have tried for days doing research with one of my friends to find any possible issues, we found nothing. I'm hoping its just a simple fix I could get some help with here. Below is also my leaderboard script if that helps any. Thanks in advance!
local Players = game:GetService("Players")
local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Krak = Instance.new("IntValue")
Krak.Name = "Krak"
Krak.Value = 10000
Krak.Parent = leaderstats
end
Players.PlayerAdded:Connect(leaderboardSetup)

3 comments
WaitForChild and FindFirstChild are functions, you're forgetting the parentheses
What is the script parented to?
The leaderboard script is in game.serverscriptstorage and the "Cash on Kill" script is parented to the model of the zombie if that answers your question.