✓ Accepted answer
First off, when you are referencing the zombie in line one, this will only work if there is only one zombie in the whole workspace. Second, when you are referencing the player in line 2, you are only getting the folder where the players are, not all the players, and then when you check to see when the zombie died, you need to use .Died:Connect to connect it to a function to use, and you
are supposed giving it an infinite amount of money over and over again. Then when you are referencing an instanced value in inside the player, you need to define the .Value afterwards.
This might be what the final product would be:
local players = game.Players:GetPlayers()
local zombie = game.Workspace:FindFirstChild("Zombie")
zombie.Humanoid.Died:Connect(function()
for i, v in pairs(players)do
v.RealMoney.Value = v.RealMoney.Value + 5
end
end)
This script would identify the zombie in game, and when it dies give every player 5 money, but it only works for one zombie, what I would suggest doing is making a local script inside the zombie itself, so when it dies it fires a remote event to the server telling it to only give it to a certain player, and this way it will work with multiple zombies.
EDIT: after looking at your comments, you could leave out the for i, v in pairs() because it's only a one person server, so it might look like this:
local players = game.Players:GetPlayers()
local zombie = game.Workspace:FindFirstChild("Zombie")
zombie.Humanoid.Died:Connect(function()
players[1].RealMoney.Value = players[1].RealMoney.Value + 5
end)
2 comments
You have to find out who killed the zombie
It is a 1 man server, would I use game.localplayer ?