Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there another way to store the player as a variable because the script isn't looping?

"RealMoney" is the currency and is in the player not in leaderstats "Zombie" is the name of the zombie and I renamed the humanoid into Zombie The script works once, For example when the Zombie dies money is given but when it respawns and I kill it again nothing happens.

local Humanoid = game.Workspace.Zombie

game:GetService('Players').PlayerAdded:Connect(function(player)
        player.CharacterAdded:Connect(function(character)
            Zombie:WaitForChild("Zombie").Died:Connect(function()
                player.RealMoney.Value = player.RealMoney.Value + 1000
            end)
        end)
    end)

1 answer

✓ Accepted answer

You'd want to use workspace.ChildAdded so that when new zombies get added, and they die, the player gets money again Keep in mind that this will only work if the zombie gets added to workspace

workspace.ChildAdded:Connect(function(zombie)
	if zombie.Name == "Zombie" then
		zombie:WaitForChild("Zombie"),Died:Connect(function()
			player.RealMoney.Value = player.RealMoney.Value + 1000
		end)
	end
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.